🚚 Move backend tests outside the app directory (#1862)
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
coverage run -m pytest
|
||||
coverage run -m pytest tests/
|
||||
coverage report
|
||||
coverage html --title "${@-coverage}"
|
||||
|
||||
@@ -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(
|
||||
@@ -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:
|
||||
@@ -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(
|
||||
@@ -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)
|
||||
@@ -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:
|
||||
@@ -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:
|
||||
@@ -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(
|
||||
Reference in New Issue
Block a user