def test_parse_search_with_missing_services_fails(self): data = { 'location': { 'name': 'Southampton Central', 'crs': 'SOU', 'tiploc': 'SOTON' }, 'filter': None } with self.assertRaises(ValueError): parser.parse_search(data)
def search_station_arrivals(self, station_code: str) -> SearchResult: """ Requests the list of upcoming arrivals at a given station. :param station_code: Either the three-letter CRS station code (CRS, e.g. 'CLJ') or the longer TIPLOC code (e.g. 'CLPHMJC') :return: A rttapi.model.SearchResult object mirroring the JSON reply """ json = self.__api.fetch_station_departure_info(self.credentials, station_code) return parser.parse_search(json)
def test_parse_search_without_filter(self): data = { 'location': { 'name': 'Southampton Central', 'crs': 'SOU', 'tiploc': 'SOTON' }, 'filter': None, 'services': [] } actual = parser.parse_search(data) self.assertEqual('Southampton Central', actual.location.name) self.assertEqual('SOU', actual.location.crs) self.assertEqual('SOTON', actual.location.tiploc) self.assertIsNone(actual.filter) self.assertEqual(0, len(actual.services))
def test_parse_search_with_filter(self): data = { 'location': { 'name': 'Southampton Central', 'crs': 'SOU', 'tiploc': 'SOTON' }, 'filter': { 'name': 'Basingstoke', 'crs': 'BSK', 'tiploc': 'BSNGSTK' }, 'services': None } actual = parser.parse_search(data) self.assertEqual('Southampton Central', actual.location.name) self.assertEqual('SOU', actual.location.crs) self.assertEqual('SOTON', actual.location.tiploc) self.assertEqual('Basingstoke', actual.filter.name) self.assertEqual('BSK', actual.filter.crs) self.assertEqual('BSNGSTK', actual.filter.tiploc) self.assertEqual(0, len(actual.services))
def test_parse_search_with_missing_location_fails(self): data = {'filter': None, 'services': None} with self.assertRaises(ValueError): parser.parse_search(data)