Skip to content

[good-first-issue] Expand AnalyticsService test coverage for get_stats edge cases #37

Description

@Metrohan

What to build / Ne yapılacak

EN: tests/unit/test_analytics_service.py covers the empty-DB shape, basic log_request increment, and simple top_pages sorting — but not the today_visitors vs total_visitors distinction in get_stats() (app/services/analytics_service.py) when requests span multiple days, nor a tie-breaker case in top_pages ordering when two paths have equal counts.

TR: tests/unit/test_analytics_service.py boş veritabanı durumunu, temel log_request artışını ve basit top_pages sıralamasını test ediyor — ama get_stats() fonksiyonundaki (app/services/analytics_service.py) today_visitors ile total_visitors ayrımını (istekler birden fazla güne yayıldığında) ve top_pages sıralamasında eşit sayıda isteğe sahip iki path arasındaki tie-breaker davranışını test etmiyor.

Files

  • tests/unit/test_analytics_service.py (add tests here)
  • app/services/analytics_service.py (read-only reference for behavior)

Acceptance criteria

  • Add a test that logs requests across two different days and asserts today_visitors only counts the current day while total_visitors counts all of them (use the existing test_db fixture; insert TrafficLog rows directly with an explicit timestamp if log_request doesn't accept one)
  • Add a test for top_pages ordering when two or more paths have identical request counts — assert the result is stable/deterministic (document the actual tie-break behavior, don't assume one)
  • Follow the existing fixture and assertion style already used in the file
  • All new and existing tests pass with pytest tests/unit/test_analytics_service.py -v

Blocked by

None — can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions