Skip to content

Commit

Permalink
bug fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Jul 9, 2024
1 parent 97087b2 commit a5ed11c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ async def post_reports(
_data = []
for d in data:
_d = d.model_dump()
_d["reported_id"] = players.get(_d.pop("reported"))
_d["reporter_id"] = players.get(_d.pop("reporter"))
reported = player_repo.sanitize_name(_d.pop("reported"))
reporter = player_repo.sanitize_name(_d.pop("reporter"))
_d["reported_id"] = players.get(reported)
_d["reporter_id"] = players.get(reporter)
_data.append(ParsedDetection(**_d))
await report_repo.send_to_kafka(data=_data)
return Ok()
17 changes: 17 additions & 0 deletions tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ async def test_valid_report(custom_client):
assert response.status_code == 201


@pytest.mark.asyncio
async def test_valid_report_weird_name(custom_client):
global example_data
endpoint = "/v2/report"
_data = example_data.copy()
_data["ts"] = int(time.time())
_data["reported"] = "plAYEr2"

# Example of a valid detection data
detection_data = [_data]

async with custom_client as client:
client: AsyncClient
response = await client.post(endpoint, json=detection_data)
assert response.status_code == 201


@pytest.mark.asyncio
async def test_invalid_ts_high_report(custom_client):
global example_data
Expand Down

0 comments on commit a5ed11c

Please sign in to comment.