Skip to content

Conversation

@MatthewBarghout
Copy link
Collaborator

Changes:
New Files Created

  1. backend/src/modules/police/police_router.py - Police router with two new endpoints:
    - POST /api/police/locations/{location_id}/warnings - Increments warning count
    - POST /api/police/locations/{location_id}/citations - Increments citation count
    - Both routes require police or admin authentication
  2. backend/test/modules/police/police_router_test.py - Comprehensive test suite with 5 test cases:
    - Test incrementing warnings as police
    - Test incrementing citations as admin
    - Test location not found (404)
    - Test unauthenticated access for warnings (401)
    - Test unauthenticated access for citations (401)

Modified Files

  1. backend/src/modules/location/location_service.py - Added two service methods:
    - increment_warnings(location_id) - Increments warning_count by 1
    - increment_citations(location_id) - Increments citation_count by 1
  2. backend/src/main.py - Registered the police_router

Closes: #87

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

Test Results Summary

347 tests  +12   347 ✅ +12   8s ⏱️ ±0s
  1 suites ± 0     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 299bab7. ± Comparison against base commit e493961.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@manyuagashe manyuagashe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ensure that code validates for numerical edge cases? Like we can never have a negative amount of warning/cites, that we handle any overflow, so on



@pytest.mark.asyncio
async def test_increment_warnings_location_not_found(
Copy link
Collaborator

@manyuagashe manyuagashe Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a testing location not found for warnings but I do not see one for citations



@pytest.mark.asyncio
async def test_increment_citations_as_admin(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you test to ensure staff/student can't increment?

@manyuagashe manyuagashe merged commit 2d0d974 into main Nov 25, 2025
2 checks passed
@naasanov naasanov deleted the warning-complaint-increment-routes branch December 2, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning and Complaint Increment Routes

3 participants