Skip to content

Commit

Permalink
fix(session_id): return int (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayceslesar authored Jun 22, 2024
1 parent 0c0afce commit f0647d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions masterbase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def session_id(
demo_name: str,
fake_ip: str,
map: str,
) -> dict[str, str]:
) -> dict[str, int]:
"""Return a session ID, as well as persist to database.
This is to help us know what is happening downstream:
Expand All @@ -89,7 +89,7 @@ def session_id(
fake_ip = f"{resolve_hostname(fake_ip)}:{port}"
start_session_helper(engine, steam_id, str(_session_id), demo_name, fake_ip, map)

return {"session_id": str(_session_id)}
return {"session_id": _session_id}


@get("/close_session", guards=[valid_key_guard, user_not_in_session_guard], sync_to_thread=False)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def _send_demo_file(test_client: TestClient[Litestar], api_key: str, session_id:
def test_demo_streaming(test_client: TestClient[Litestar], api_key: str) -> None:
"""Test streaming a demo to the DB."""
session_id = _open_mock_session(test_client, api_key).json()["session_id"]
_send_demo_file(test_client, api_key, session_id)
assert isinstance(session_id, int)

_send_demo_file(test_client, api_key, str(session_id))

late_bytes_hex = "7031cf44a7af0100cea70100f5e00400"
late_bytes_response = test_client.post(
Expand All @@ -130,7 +132,7 @@ def test_demo_streaming(test_client: TestClient[Litestar], api_key: str) -> None

def test_db_exports(test_client: TestClient[Litestar], api_key: str) -> None:
"""Test on-demand exports from the database."""
session_id = _open_mock_session(test_client, api_key).json()["session_id"]
session_id = str(_open_mock_session(test_client, api_key).json()["session_id"])
# Insert mock reports
expected = []
for i in range(10):
Expand All @@ -157,7 +159,7 @@ def test_db_exports(test_client: TestClient[Litestar], api_key: str) -> None:

def test_upsert_report_reason(test_client: TestClient[Litestar], api_key: str) -> None:
"""Ensure that upserts of reports during the same session work as intended."""
session_id = _open_mock_session(test_client, api_key).json()["session_id"]
session_id = str(_open_mock_session(test_client, api_key).json()["session_id"])
engine = test_client.app.state.engine
target_sid = f"{0:020d}"
add_report(engine, session_id, target_sid, reason="bot")
Expand Down

0 comments on commit f0647d3

Please sign in to comment.