Esempio n. 1
0
def test_get_timetable_list_200(timetable_list_response):
    expected_url = V1_TIMETABLES_URL + "/"

    key = "apikey"
    client = BODSClient(api_key=key)
    with patch("bods_client.client.BODSClient._make_request") as mrequests:
        mrequests.return_value = timetable_list_response
        client.get_timetable_datasets()
        expected_params = {"limit": 25, "offset": 0}
        mrequests.assert_called_once_with(expected_url, params=expected_params)
Esempio n. 2
0
def test_get_timetable_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_timetable_datasets()

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

    key = "apikey"
    client = BODSClient(api_key=key)
    params = TimetableParams(limit=10, nocs=["NT"])
    client.get_timetable_datasets(params=params)

    expected_params = {"limit": 10, "offset": 0, "noc": ["NT"]}
    mrequests.assert_called_once_with(client.timetable_endpoint,
                                      params=expected_params)