Exemplo n.º 1
0
def test_get_fare_list_200(fare_list_response):
    expected_url = V1_FARES_URL + "/"

    key = "apikey"
    client = BODSClient(api_key=key)
    with patch("bods_client.client.BODSClient._make_request") as mrequests:
        mrequests.return_value = fare_list_response
        client.get_fares_datasets()
        expected_params = {"limit": 25, "offset": 0}
        mrequests.assert_called_once_with(expected_url, params=expected_params)
Exemplo n.º 2
0
def test_get_fares_datasets_no_params(mrequests):
    response = MagicMock(spec=Response, status_code=400, content=b"Oopsie")
    mrequests.return_value = response

    key = "apikey"
    client = BODSClient(api_key=key)
    client.get_fares_datasets()

    expected_params = {"limit": 25, "offset": 0}
    mrequests.assert_called_once_with(client.fares_endpoint,
                                      params=expected_params)
Exemplo n.º 3
0
def test_get_fares_datasets_bounding_box(mrequests):
    response = MagicMock(spec=Response, status_code=400, content=b"Oopsie")
    mrequests.return_value = response

    key = "apikey"
    client = BODSClient(api_key=key)
    bb = {
        "min_longitude": -0.542423,
        "min_latitude": 51.267729,
        "max_longitude": 0.277432,
        "max_latitude": 51.753191,
    }
    bounding_box = BoundingBox(**bb)
    params = FaresParams(limit=10, bounding_box=bounding_box)
    client.get_fares_datasets(params=params)

    expected_params = {
        "limit": 10,
        "offset": 0,
        "boundingBox": bounding_box.csv()
    }
    mrequests.assert_called_once_with(client.fares_endpoint,
                                      params=expected_params)