Skip to content

Commit 6c880e1

Browse files
committed
fix(tests): whole test suite can now be run
1 parent 4873317 commit 6c880e1

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ ignore = ["E501", "F401", "N806"]
6666
# [Based]Pyright: Type checker/LSP
6767
[tool.pyright]
6868
executionEnvironments = [
69-
{ root = "src", pythonVersion = "3.11" }
69+
{ root = "src", pythonVersion = "3.11" },
70+
{ root = "tests", extraPaths=["src"], pythonVersion = "3.11" }
7071
]
7172
typeCheckingMode = "standard"
7273
reportAny = "none" # Allow the use of `Any` type

src/officers/crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
async def current_officers(
20-
db_session: database.DBSession, include_private: bool
20+
db_session: database.DBSession, include_private: bool = False
2121
) -> list[OfficerPrivate] | list[OfficerPublic]:
2222
"""
2323
Get info about officers that are active. Go through all active & complete officer terms.
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import pytest_asyncio
88
from httpx import ASGITransport, AsyncClient
99

10-
from src import load_test_db
11-
from src.auth.crud import create_user_session, remove_user_session
12-
from src.database import SQLALCHEMY_TEST_DATABASE_URL, DatabaseSessionManager
13-
from src.main import app
10+
from auth.crud import create_user_session, remove_user_session
11+
from database import SQLALCHEMY_TEST_DATABASE_URL, DatabaseSessionManager
12+
from load_test_db import SYSADMIN_COMPUTING_ID, async_main
13+
from main import app
1414

1515

1616
# This might be able to be moved to `package` scope as long as I inject it to every test function
@@ -20,17 +20,19 @@ def suppress_sqlalchemy_logs():
2020
yield
2121
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
2222

23+
2324
@pytest_asyncio.fixture(scope="session", loop_scope="session")
2425
async def database_setup():
2526
# reset the database again, just in case
2627
print("Resetting DB...")
2728
sessionmanager = DatabaseSessionManager(SQLALCHEMY_TEST_DATABASE_URL, {"echo": False}, check_db=False)
2829
# this resets the contents of the database to be whatever is from `load_test_db.py`
29-
await load_test_db.async_main(sessionmanager)
30+
await async_main(sessionmanager)
3031
print("Done setting up!")
3132
yield sessionmanager
3233
await sessionmanager.close()
3334

35+
3436
@pytest_asyncio.fixture(scope="session", loop_scope="session")
3537
async def client() -> AsyncGenerator[Any, None]:
3638
# base_url is just a random placeholder url
@@ -39,18 +41,18 @@ async def client() -> AsyncGenerator[Any, None]:
3941
async with AsyncClient(transport=ASGITransport(app), base_url="http://test") as client:
4042
yield client
4143

44+
4245
@pytest_asyncio.fixture(scope="function", loop_scope="session")
4346
async def db_session(database_setup):
4447
async with database_setup.session() as session:
4548
yield session
4649

50+
4751
@pytest_asyncio.fixture(scope="module", loop_scope="session")
4852
async def admin_client(database_setup, client):
49-
session_id = "temp_id_" + load_test_db.SYSADMIN_COMPUTING_ID
50-
client.cookies = { "session_id": session_id }
53+
session_id = "temp_id_" + SYSADMIN_COMPUTING_ID
54+
client.cookies = {"session_id": session_id}
5155
async with database_setup.session() as session:
52-
await create_user_session(session, session_id, load_test_db.SYSADMIN_COMPUTING_ID)
56+
await create_user_session(session, session_id, SYSADMIN_COMPUTING_ID)
5357
yield client
5458
await remove_user_session(session, session_id)
55-
56-

0 commit comments

Comments
 (0)