Exemplo n.º 1
0
def test_get_enum_url_parameter__invalid(flask_request):
    class TestEnum(enum.Enum):
        VALUE_A = 0
        VALUE_B = 1

    flask_request.args = {"my_param": "value_c"}

    with pytest.raises(exceptions.InvalidInput):
        httpmanager.get_enum_url_parameter("my_param", TestEnum)
Exemplo n.º 2
0
def test_get_enum_url_parameter__base_case(flask_request, value):
    class TestEnum(enum.Enum):
        VALUE_A = 0
        VALUE_B = 1

    flask_request.args = {"my_param": "value_a"}

    assert TestEnum.VALUE_A == httpmanager.get_enum_url_parameter(
        "my_param", TestEnum)
Exemplo n.º 3
0
def test_get_enum_url_parameter__default_case(flask_request):
    class TestEnum(enum.Enum):
        VALUE_A = 0
        VALUE_B = 1

    flask_request.args = {}

    assert TestEnum.VALUE_A == httpmanager.get_enum_url_parameter(
        "my_param", TestEnum, TestEnum.VALUE_A)
Exemplo n.º 4
0
def list_all_in_system(system_id):
    """
    List agencies in a system
    """
    return agencyservice.list_all_in_system(
        system_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 5
0
def get_in_system_by_id(system_id, agency_id):
    """
    Get an agency in a system
    """
    return agencyservice.get_in_system_by_id(
        system_id,
        agency_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 6
0
def list_all_in_system(system_id):
    """
    List stops in a system

    List all the stops in a transit system.

    Return code     | Description
    ----------------|-------------
    `200 OK`        | Returned if the system with this ID exists.
    `404 NOT FOUND` | Returned if no system with the provided ID is installed.
    """
    return stopservice.list_all_in_system(
        system_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 7
0
def get_in_system_by_id(system_id, route_id):
    """
    Get a route in a system

    Describe a route in a transit system.

    Return code         | Description
    --------------------|-------------
    `200 OK`            | Returned if the system and route exist.
    `404 NOT FOUND`     | Returned if either the system or the route does not exist.
    """
    return routeservice.get_in_system_by_id(
        system_id,
        route_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 8
0
def list_all_in_route(system_id, route_id):
    """
    List trips in a route

    List all the realtime trips in a particular route.

    Return code     | Description
    ----------------|-------------
    `200 OK`        | Returned if the system and route exist.
    `404 NOT FOUND` | Returned if either the system or the route does not exist.
    """
    return tripservice.list_all_in_route(
        system_id,
        route_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 9
0
def get_in_route_by_id(system_id, route_id, trip_id):
    """
    Get a trip in a route

    Describe a trip in a route in a transit system.

    Return code         | Description
    --------------------|-------------
    `200 OK`            | Returned if the system, route and trip exist.
    `404 NOT FOUND`     | Returned if the system, route or trip do not exist.
    """
    return tripservice.get_in_route_by_id(
        system_id,
        route_id,
        trip_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
    )
Exemplo n.º 10
0
def get_in_system_by_id(system_id, stop_id):
    """
    Get a stop in a system

    Describe a stop in a transit system.

    Return code         | Description
    --------------------|-------------
    `200 OK`            | Returned if the system and stop exist.
    `404 NOT FOUND`     | Returned if either the system or the stop does not exist.
    """
    request_args = get_url_parameters(
        [
            "minimum_number_of_trips", "include_all_trips_within",
            "exclude_trips_before"
        ],
        error_if_extra_keys=False,
    )
    return stopservice.get_in_system_by_id(
        system_id,
        stop_id,
        alerts_detail=get_enum_url_parameter("alerts_detail",
                                             views.AlertsDetail),
        **request_args)