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

TLK-2622 Unit tests improvements #907

Conversation

EugeneLightsOn
Copy link
Collaborator

@EugeneLightsOn EugeneLightsOn commented Jan 15, 2025

Unit tests improvements

AI Description

This PR introduces several changes to the backend unit tests and configuration files, primarily focusing on database setup and test fixtures.

  • Database Configuration: The DATABASE_URL in src/backend/pytest.ini has been updated to remove the database name, and a new ignore::DeprecationWarning has been added.
  • Alembic Configuration: In src/backend/alembic/env.py, the sqlalchemy.url value is now set only if it is not already set.
  • Test Fixtures: The engine and session_chat fixtures in src/backend/tests/unit/conftest.py have been modified to use the worker_id to create a unique test database for each worker. The session_client and session_client_chat fixtures now accept the fastapi_app fixture as an argument, and the fastapi_app fixture has been added to create a session-scoped FastAPI app object.
  • Test Scope: The scope of the user fixture in src/backend/tests/integration/routers/test_chat.py has been changed from function to session.</co: 5>
  • Run Unit Tests: The command to run unit tests in .github/workflows/backend_unit_tests.yml has been updated from make run-unit-tests-debug to make run-unit-tests.
  • Type Hinting: The create_app function in src/backend/main.py and src/backend/pycharm_debug_main.py now includes a return type hint of FastAPI.

@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.

Project coverage is 76.75%. Comparing base (6a81440) to head (e80c0a6).

Files with missing lines Patch % Lines
src/backend/alembic/env.py 50.00% 1 Missing ⚠️
src/backend/pycharm_debug_main.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #907      +/-   ##
==========================================
+ Coverage   76.72%   76.75%   +0.02%     
==========================================
  Files         272      272              
  Lines       10620    10638      +18     
==========================================
+ Hits         8148     8165      +17     
- Misses       2472     2473       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…api-app-once-when-building-test-fixtures

# Conflicts:
#	src/backend/main.py
@EugeneLightsOn EugeneLightsOn merged commit 9ce3c5c into main Jan 16, 2025
8 checks passed
@EugeneLightsOn EugeneLightsOn deleted the eugene1/tlk-2622-instantiate-fastapi-app-once-when-building-test-fixtures branch January 16, 2025 10:30
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.

3 participants