async def test_route_specific_monthly_usage(limits_handler):
    """Confirm that monthly usage is tracked per-route and doesn't get
    incremented by calls to other routes."""
    # 1) Clear existing logs
    clear_query = f"DELETE FROM {limits_handler._get_table_name(limits_handler.TABLE_NAME)}"
    await limits_handler.connection_manager.execute_query(clear_query)

    # 2) Setup
    user_id = uuid.uuid4()
    routeA = "/v3/retrieval/rag"
    routeB = "/v3/retrieval/search"
    test_user = User(
        id=user_id,
        email="test_monthly_routes@example.com",
        is_active=True,
        is_verified=True,
        is_superuser=False,
        limits_overrides=None,
    )

    # 3) Log 5 requests for routeA
    for _ in range(5):
        await limits_handler.log_request(user_id, routeA)

    # 4) Check monthly usage for routeA => should be 5
    routeA_monthly = await limits_handler._count_monthly_requests(
        user_id, routeA)
    assert routeA_monthly == 5, f"Expected 5 for routeA, got {routeA_monthly}"

    # routeB => should still be 0
    routeB_monthly = await limits_handler._count_monthly_requests(
        user_id, routeB)
    assert routeB_monthly == 0, f"Expected 0 for routeB, got {routeB_monthly}"

    # 5) Now log 3 requests for routeB
    for _ in range(3):
        await limits_handler.log_request(user_id, routeB)

    # Re-check usage
    routeA_monthly_after = await limits_handler._count_monthly_requests(
        user_id, routeA)
    routeB_monthly_after = await limits_handler._count_monthly_requests(
        user_id, routeB)
    assert routeA_monthly_after == 5, (
        f"RouteA usage changed unexpectedly: {routeA_monthly_after}")
    assert routeB_monthly_after == 3, (
        f"RouteB usage is wrong: {routeB_monthly_after}")

    # Additionally confirm total usage across all routes
    global_monthly = await limits_handler._count_monthly_requests(user_id,
                                                                  route=None)
    assert global_monthly == 8, (
        f"Expected total of 8 monthly requests, got {global_monthly}")
Confirm that monthly usage is tracked per-route and doesn't get
    incremented by calls to other routes.
py/tests/unit/database/test_limits.py