Skip to content

Commit

Permalink
Add pytest (#45) (#55)
Browse files Browse the repository at this point in the history
* Add pytest (#45)

* Add pytest (#45)

* Add pytest-django (#45)

* Add pytest-django (#45)

* Add pytest (#45)

* s

* fix flake8

---------

Co-authored-by: Konstantin Raikhert <raikhert13@gmail.com>
  • Loading branch information
nrthbnd and KonstantinRaikhert authored Dec 18, 2023
1 parent dafdd2d commit 6c68d4a
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
exclude: migrations/|.*settings(\.py|/)?
exclude: migrations/|config/|.*settings(\.py|/)?
additional_dependencies:
- flake8-isort
- flake8-django
Expand All @@ -41,4 +41,4 @@ repos:
language: system
pass_filenames: false
entry: poetry export --without-hashes --output requirements/production.txt
files: ^(pyproject.toml|poetry.lock)$
files: ^(pyproject.toml|poetry.lock)$
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Определение переменных
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
MANAGE_DIR := $(PROJECT_DIR)/adaptive_hockey_federation/manage.py
DJANGO_DIR := $(PROJECT_DIR)/adaptive_hockey_federation
POETRY_RUN := poetry run python
DJANGO_RUN := $(POETRY_RUN) $(MANAGE_DIR)
SHELL_GREEN = \033[32m
Expand All @@ -22,6 +23,7 @@ help:
@echo " createsuperuser - $(SHELL_GREEN)Команда для создания супер-юзера.$(SHELL_NC)"
@echo " run - $(SHELL_GREEN)Команда для локального запуска проекта.$(SHELL_NC)"
@echo " fill-db - $(SHELL_GREEN)Команда для заполнения базы данных с помощью парсера.$(SHELL_NC)"
@echo " pytest - $(SHELL_GREEN)Команда для прогона юнит тестов pytest.$(SHELL_NC)"
@echo " help - $(SHELL_GREEN)Команда вызова справки.$(SHELL_NC)"
@echo "$(SHELL_YELLOW)Для запуска исполнения команд используйте данные ключи совместно с командой 'make', например 'make init-app'."
@echo "При запуске команды 'make' без какого либо ключа, происходит вызов справки.$(SHELL_NC)"
Expand Down Expand Up @@ -61,4 +63,9 @@ run:
fill-db:
cd $(PROJECT_DIR) && $(DJANGO_RUN) fill-db

# Прогон тестов с помощью pytest
pytest:
cd $(DJANGO_DIR) && pytest


.PHONY: help
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

os.environ.setdefault(
'DJANGO_SETTINGS_MODULE',
'adaptive_hockey_federation.settings'
'core.config.dev_settings',
)

application = get_asgi_application()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# import environ

BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent.parent

# env = environ.Env(DEBUG=(bool, False))

Expand Down Expand Up @@ -39,7 +39,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'adaptive_hockey_federation.urls'
ROOT_URLCONF = 'core.urls'

TEMPLATES_DIR = BASE_DIR / 'templates'

Expand All @@ -59,7 +59,7 @@
},
]

WSGI_APPLICATION = 'adaptive_hockey_federation.wsgi.application'
WSGI_APPLICATION = 'core.wsgi.application'

DATABASES = {
'default': {
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.core.management.base import BaseCommand

from adaptive_hockey_federation.settings import RESOURSES_ROOT
from adaptive_hockey_federation.core.config.dev_settings import RESOURSES_ROOT


class Command(BaseCommand):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

os.environ.setdefault(
'DJANGO_SETTINGS_MODULE',
'adaptive_hockey_federation.settings'
'core.config.dev_settings',
)

application = get_wsgi_application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.8 on 2023-12-16 13:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0002_alter_player_patronymic'),
]

operations = [
migrations.AlterField(
model_name='player',
name='patronymic',
field=models.CharField(blank=True, default='--пусто--', help_text='Отчество', max_length=256, verbose_name='Отчество'),
),
]
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'adaptive_hockey_federation.settings')
'core.config.dev_settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/parser/docx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import docx # type: ignore

from adaptive_hockey_federation.core.user_card import BaseUserInfo
from adaptive_hockey_federation.parser.user_card import BaseUserInfo

NAME = '[И|и][М|м][Я|я]'
SURNAME = '[Ф|ф][А|а][М|м][И|и][Л|л][И|и][Я|я]'
Expand Down
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/parser/xlsx_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import openpyxl

from adaptive_hockey_federation.core.user_card import BaseUserInfo
from adaptive_hockey_federation.parser.user_card import BaseUserInfo


def xlsx_parser(path: str) -> list[BaseUserInfo]:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ sleep 5
app/.venv/bin/python manage.py collectstatic --noinput
mv /static/* /app/static/

exec "$@"
exec "$@"
Loading

0 comments on commit 6c68d4a

Please sign in to comment.