Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add tests for tasks and files api #101

Merged
merged 26 commits into from
Dec 6, 2024

Conversation

ArtemBalandin81
Copy link
Owner

@ArtemBalandin81 ArtemBalandin81 commented Nov 22, 2024

  • Добавлены тесты для тестирования задач в апи: tests/test_routes/test_task.py
  • Добавлены фикстуры задач в rtests/conftest.pyr
  • Выявлен баг response в /api/tasks/my_tasks_todo: почта пользователя и исполнителя совпадают - такого быть не должно.
    upd. Баг оперативно исправлен в: src/api/endpoints/tasks.py в async def get_my_tasks_todo добавлен None
    return await task_service.perform_changed_schema(await task_service.get_my_tasks_todo(user.id), None, user)
{
    "Задача: ": "Тестовая доккер",
    "Описание задачи: ": "Тестируем приложение в доккер",
    "Дата постановки задачи": "15-06-2024",
    "Дедлайн по задаче: ": "22-06-2024",
    "Тех-процесс: ": "DU_25",
    "Исполнитель задачи: ": 4,
    "is_archived": false,
    "id": 20,
    "Дата создания": "15-06-2024: 09:09",
    "Дата обновления": "15-06-2024: 09:09",
    "Почта пользователя": "[email protected]",
    "Почта исполнителя": "[email protected]",
    "Привязанные файлы: ": [
      "15-06-2024_090949_image_violet.gif"
    ],
    "Дней на задачу": -153
  },
  • в @task_router.get( добавлена зависимость dependencies=[Depends(current_user)]

  • Добавлены тесты для тестирования сервиса работы с файлами в апи: tests/test_routes/test_attached_files.py

  • В src/api/endpoints/files_attached.py добавлены схемы ответов status.HTTP_401 и status.HTTP_403;

  • В эндпоинте неспользуемых файлов async def get_files_unused сменил рут с FILE_ID, на MAIN_ROUTE

  • Небольшие изменения в тестах простоев: tests/test_routes/test_suspension.py

    • Обновлены:
      starlette "0.37.2 ">>> version = "0.41.3"
      fastapi "0.111.0" >>> version = "0.115.6 "
      cryptography "42.0.7" >>> version = 44.0.0 (wanted at least 43.0.1)
      python-multipart >>> version = ??? wanted 0.0.18
      !!! - Removing jinja2 (3.1.4)
      !!! - Removing orjson (3.10.3)
      ??? - Removing pygments (2.18.0)
    • Updating httpx (0.27.0) >>> 0.28.0 raisis type error
      TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app'
  • в tests/conftest.py избавились от функции def start_application(), объединив ее с:

@pytest.fixture(scope="function")
def app() -> Generator[FastAPI, Any, None]:
    """Start app"""
    # _app = start_application()  # - another solution has been chosen
    _app = FastAPI()
    _app.include_router(api_router)
    yield _app
  • не забыть обновить файл requirements:
    poetry export --without-hashes > requirements.txt

@ArtemBalandin81
Copy link
Owner Author

Зависимости до изменения:

$ poetry show
aiosqlite                   0.19.0      asyncio bridge to the standard sqlite3 module
alembic                     1.13.1      A database migration tool for SQLAlchemy.
annotated-types             0.7.0       Reusable constraint types to use with typing.Annotated
anyio                       4.3.0       High level compatibility layer for multiple asynchronous event loop implementations
asgi-correlation-id         4.2.0       Middleware correlating project logs to individual requests
asyncpg                     0.27.0      An asyncio PostgreSQL driver
attrs                       23.2.0      Classes Without Boilerplate
bcrypt                      4.1.3       Modern password hashing for your software and your servers
certifi                     2024.7.4    Python package for providing Mozilla's CA Bundle.
cffi                        1.16.0      Foreign Function Interface for Python calling C code.
charset-normalizer          3.3.2       The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet.
click                       8.1.7       Composable command line interface toolkit
colorama                    0.4.6       Cross-platform colored terminal text.
cryptography                42.0.7      cryptography is a package which provides cryptographic recipes and primitives to Python developers.
dnspython                   2.6.1       DNS toolkit
email-validator             2.1.1       A robust email address syntax and deliverability validation library.
fastapi                     0.111.0     FastAPI framework, high performance, easy to learn, fast to code, ready for production
fastapi-cli                 0.0.4       Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
fastapi-users               12.1.3      Ready-to-use and customizable users management for FastAPI
fastapi-users-db-sqlalchemy 6.0.1       FastAPI Users database adapter for SQLAlchemy
flake8                      6.1.0       the modular source code checker: pep8 pyflakes and co
greenlet                    3.0.3       Lightweight in-process concurrent programming
h11                         0.14.0      A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
httpcore                    1.0.5       A minimal low-level HTTP client.
httptools                   0.6.1       A collection of framework independent HTTP protocol utils.
httpx                       0.27.0      The next generation HTTP client.
idna                        3.7         Internationalized Domain Names in Applications (IDNA)
iniconfig                   2.0.0       brain-dead simple config-ini parsing
isort                       5.13.2      A Python utility / library to sort Python imports.
jinja2                      3.1.4       A very fast and expressive template engine.
makefun                     1.15.2      Small library to dynamically create python functions.
mako                        1.3.5       A super-fast templating language that borrows the best ideas from the existing templating languages.
markdown-it-py              3.0.0       Python port of markdown-it. Markdown parsing, done right!
markupsafe                  2.1.5       Safely add untrusted strings to HTML/XML markup.
mccabe                      0.7.0       McCabe checker, plugin for flake8
mdurl                       0.1.2       Markdown URL utilities
numpy                       1.26.4      Fundamental package for array computing in Python
orjson                      3.10.3      Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
outcome                     1.3.0.post0 Capture the outcome of Python function calls.
packaging                   24.1        Core utilities for Python packages
passlib                     1.7.4       comprehensive password hashing framework supporting over 30 schemes
pluggy                      1.5.0       plugin and hook calling mechanisms for python
pycodestyle                 2.11.1      Python style guide checker
pycparser                   2.22        C parser in Python
pydantic                    2.6.4       Data validation using Python type hints
pydantic-core               2.16.3     
pydantic-settings           2.2.1       Settings management using Pydantic
pyflakes                    3.1.0       passive checker of Python programs
pygments                    2.18.0      Pygments is a syntax highlighting package written in Python.
pyjwt                       2.8.0       JSON Web Token implementation in Python
pytest                      8.2.2       pytest: simple powerful testing with Python
pytest-sugar                1.0.0       pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show te...  
python-dotenv               1.0.1       Read key-value pairs from a .env file and set them as environment variables
python-multipart            0.0.7       A streaming multipart parser for Python
pyyaml                      6.0.1       YAML parser and emitter for Python
requests                    2.32.2      Python HTTP for Humans.
rich                        13.7.1      Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
shellingham                 1.5.4       Tool to Detect Surrounding Shell
sniffio                     1.3.1       Sniff out which async library your code is running under
sortedcontainers            2.4.0       Sorted Containers -- Sorted List, Sorted Dict, Sorted Set
sqlalchemy                  2.0.30      Database Abstraction Library
starlette                   0.37.2      The little ASGI library that shines.
structlog                   24.1.0      Structured Logging for Python
termcolor                   2.4.0       ANSI color formatting for output in terminal
trio                        0.26.0      A friendly Python library for async concurrency and I/O
typer                       0.12.3      Typer, build great CLIs. Easy to code. Based on Python type hints.
typing-extensions           4.12.0      Backported and Experimental Type Hints for Python 3.8+
ujson                       5.10.0      Ultra fast JSON encoder and decoder for Python
urllib3                     2.2.2       HTTP library with thread-safe connection pooling, file post, and more.
uvicorn                     0.21.1      The lightning-fast ASGI server.
watchfiles                  0.21.0      Simple, modern and high performance file watching and code reload in python.
websockets                  12.0        An implementation of the WebSocket Protocol (RFC 6455 & 7692)

@ArtemBalandin81
Copy link
Owner Author

AFTER UPDATING LIBRARIES:
$ poetry show

aiosqlite                   0.19.0      asyncio bridge to the standard sqlite3 module
alembic                     1.13.1      A database migration tool for SQLAlchemy.
annotated-types             0.7.0       Reusable constraint types to use with typing.Annotated
anyio                       4.3.0       High level compatibility layer for multiple asynchronous event loop implementations
asgi-correlation-id         4.2.0       Middleware correlating project logs to individual requests
asyncpg                     0.27.0      An asyncio PostgreSQL driver
attrs                       23.2.0      Classes Without Boilerplate
bcrypt                      4.1.3       Modern password hashing for your software and your servers
certifi                     2024.7.4    Python package for providing Mozilla's CA Bundle.
cffi                        1.16.0      Foreign Function Interface for Python calling C code.
charset-normalizer          3.3.2       The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet.
click                       8.1.7       Composable command line interface toolkit
colorama                    0.4.6       Cross-platform colored terminal text.
cryptography                44.0.0      cryptography is a package which provides cryptographic recipes and primitives to Python developers.
dnspython                   2.6.1       DNS toolkit
email-validator             2.1.1       A robust email address syntax and deliverability validation library.
fastapi                     0.115.6     FastAPI framework, high performance, easy to learn, fast to code, ready for production
fastapi-cli                 0.0.6       Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
fastapi-users               12.1.3      Ready-to-use and customizable users management for FastAPI
fastapi-users-db-sqlalchemy 6.0.1       FastAPI Users database adapter for SQLAlchemy
flake8                      6.1.0       the modular source code checker: pep8 pyflakes and co
greenlet                    3.0.3       Lightweight in-process concurrent programming
h11                         0.14.0      A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
httpcore                    1.0.7       A minimal low-level HTTP client.
httptools                   0.6.4       A collection of framework independent HTTP protocol utils.
httpx                       0.27.0      The next generation HTTP client.
idna                        3.7         Internationalized Domain Names in Applications (IDNA)
iniconfig                   2.0.0       brain-dead simple config-ini parsing
isort                       5.13.2      A Python utility / library to sort Python imports.
makefun                     1.15.2      Small library to dynamically create python functions.
mako                        1.3.5       A super-fast templating language that borrows the best ideas from the existing templating languages.
markdown-it-py              3.0.0       Python port of markdown-it. Markdown parsing, done right!
markupsafe                  2.1.5       Safely add untrusted strings to HTML/XML markup.
mccabe                      0.7.0       McCabe checker, plugin for flake8
mdurl                       0.1.2       Markdown URL utilities
numpy                       1.26.4      Fundamental package for array computing in Python
outcome                     1.3.0.post0 Capture the outcome of Python function calls.
packaging                   24.1        Core utilities for Python packages
passlib                     1.7.4       comprehensive password hashing framework supporting over 30 schemes
pluggy                      1.5.0       plugin and hook calling mechanisms for python
pycodestyle                 2.11.1      Python style guide checker
pycparser                   2.22        C parser in Python
pydantic                    2.6.4       Data validation using Python type hints
pydantic-core               2.16.3     
pydantic-settings           2.2.1       Settings management using Pydantic
pyflakes                    3.1.0       passive checker of Python programs
pygments                    2.18.0      Pygments is a syntax highlighting package written in Python.
pyjwt                       2.8.0       JSON Web Token implementation in Python
pytest                      8.2.2       pytest: simple powerful testing with Python
pytest-sugar                1.0.0       pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show te...  
python-dotenv               1.0.1       Read key-value pairs from a .env file and set them as environment variables
python-multipart            0.0.7       A streaming multipart parser for Python
pyyaml                      6.0.2       YAML parser and emitter for Python
requests                    2.32.2      Python HTTP for Humans.
rich                        13.9.4      Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
rich-toolkit                0.12.0      Rich toolkit for building command-line applications
shellingham                 1.5.4       Tool to Detect Surrounding Shell
sniffio                     1.3.1       Sniff out which async library your code is running under
sortedcontainers            2.4.0       Sorted Containers -- Sorted List, Sorted Dict, Sorted Set
sqlalchemy                  2.0.30      Database Abstraction Library
starlette                   0.41.3      The little ASGI library that shines.
structlog                   24.1.0      Structured Logging for Python
termcolor                   2.4.0       ANSI color formatting for output in terminal
trio                        0.26.0      A friendly Python library for async concurrency and I/O
typer                       0.15.1      Typer, build great CLIs. Easy to code. Based on Python type hints.
typing-extensions           4.12.2      Backported and Experimental Type Hints for Python 3.8+
ujson                       5.10.0      Ultra fast JSON encoder and decoder for Python
urllib3                     2.2.2       HTTP library with thread-safe connection pooling, file post, and more.
uvicorn                     0.21.1      The lightning-fast ASGI server.
watchfiles                  1.0.0       Simple, modern and high performance file watching and code reload in python.
websockets                  14.1        An implementation of the WebSocket Protocol (RFC 6455 & 7692)

@ArtemBalandin81 ArtemBalandin81 merged commit f183e5b into main Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Написать тесты для эндпоинтов задач и файлов
1 participant