-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
DATABASE_URL=sqlite+aiosqlite:///test.db | ||
|
||
JWT_SECRET=ee | ||
OAUTH2_SECRET=ee | ||
GOOGLE_OAUTH2_CLIENT_ID=ee | ||
GOOGLE_OAUTH2_CLIENT_SECRET=ee | ||
|
||
ENVIRONMENT=TEST | ||
TEST_DATABASE_URL=sqlite:///test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,10 @@ | |
from sqlalchemy import Engine | ||
from sqlmodel import Session | ||
|
||
from src.auth.dependency import current_active_user | ||
from src.main import app | ||
from tests.database import engine | ||
from tests.utils.auth import create_random_user | ||
from tests.utils.database import create_all_table, drop_tables | ||
|
||
|
||
|
@@ -28,3 +30,14 @@ def database(): | |
def session(database: Engine) -> Generator[Session, Any, None]: | ||
with Session(engine) as session: | ||
yield session | ||
|
||
|
||
"""override dependencies""" | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def override_dependencies(session: Session): | ||
def override_current_active_user(): | ||
return create_random_user(session, email="[email protected]") | ||
|
||
app.dependency_overrides[current_active_user] = override_current_active_user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from sqlmodel import Session | ||
|
||
from src.auth.model import User | ||
|
||
QUIZ_SCREENSHOT_COUNT = 5 | ||
|
||
|
||
def create_random_user( | ||
session: Session, *, email: str, is_active: bool = True, is_superuser: bool = False, is_verified: bool = False | ||
) -> User: | ||
user = User( | ||
email=email, | ||
hashed_password="hashed_password", | ||
is_active=is_active, | ||
is_superuser=is_superuser, | ||
is_verified=is_verified, | ||
) | ||
|
||
session.add(user) | ||
session.commit() | ||
session.refresh(user) | ||
|
||
return user |