🚚 Move backend tests outside the app directory (#1862)

Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
This commit is contained in:
Motov Yurii
2025-09-20 18:29:10 +02:00
committed by GitHub
parent 46e86d4d4d
commit 0b473f5b6f
20 changed files with 13 additions and 12 deletions

View File

@@ -34,6 +34,7 @@ COPY ./scripts /app/scripts
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
COPY ./app /app/app
COPY ./tests /app/tests
# Sync the project
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers

View File

@@ -97,7 +97,7 @@ To test the backend run:
$ bash ./scripts/test.sh
```
The tests run with Pytest, modify and add tests to `./backend/app/tests/`.
The tests run with Pytest, modify and add tests to `./backend/tests/`.
If you use GitHub Actions the tests will run automatically.

View File

@@ -3,6 +3,6 @@
set -e
set -x
coverage run -m pytest
coverage run -m pytest tests/
coverage report
coverage html --title "${@-coverage}"

View File

@@ -4,7 +4,7 @@ from fastapi.testclient import TestClient
from sqlmodel import Session
from app.core.config import settings
from app.tests.utils.item import create_random_item
from tests.utils.item import create_random_item
def test_create_item(

View File

@@ -7,9 +7,9 @@ from app.core.config import settings
from app.core.security import verify_password
from app.crud import create_user
from app.models import UserCreate
from app.tests.utils.user import user_authentication_headers
from app.tests.utils.utils import random_email, random_lower_string
from app.utils import generate_password_reset_token
from tests.utils.user import user_authentication_headers
from tests.utils.utils import random_email, random_lower_string
def test_get_access_token(client: TestClient) -> None:

View File

@@ -8,7 +8,7 @@ from app import crud
from app.core.config import settings
from app.core.security import verify_password
from app.models import User, UserCreate
from app.tests.utils.utils import random_email, random_lower_string
from tests.utils.utils import random_email, random_lower_string
def test_get_users_superuser_me(

View File

@@ -8,8 +8,8 @@ from app.core.config import settings
from app.core.db import engine, init_db
from app.main import app
from app.models import Item, User
from app.tests.utils.user import authentication_token_from_email
from app.tests.utils.utils import get_superuser_token_headers
from tests.utils.user import authentication_token_from_email
from tests.utils.utils import get_superuser_token_headers
@pytest.fixture(scope="session", autouse=True)

View File

@@ -4,7 +4,7 @@ from sqlmodel import Session
from app import crud
from app.core.security import verify_password
from app.models import User, UserCreate, UserUpdate
from app.tests.utils.utils import random_email, random_lower_string
from tests.utils.utils import random_email, random_lower_string
def test_create_user(db: Session) -> None:

View File

@@ -2,8 +2,8 @@ from sqlmodel import Session
from app import crud
from app.models import Item, ItemCreate
from app.tests.utils.user import create_random_user
from app.tests.utils.utils import random_lower_string
from tests.utils.user import create_random_user
from tests.utils.utils import random_lower_string
def create_random_item(db: Session) -> Item:

View File

@@ -4,7 +4,7 @@ from sqlmodel import Session
from app import crud
from app.core.config import settings
from app.models import User, UserCreate, UserUpdate
from app.tests.utils.utils import random_email, random_lower_string
from tests.utils.utils import random_email, random_lower_string
def user_authentication_headers(