示例#1
0
 def test_data_print(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.')}
     boarding_card = TourSortingApi().generate_boarding_cards(initial_dataset)[0]
     self.assertEqual(boarding_card.__str__(),
                      f'Take flight SK22 from Stockholm to New York. Gate 22, seat 7B. Baggage will be '
                      f'automatically transferred from your last leg.')
示例#2
0
 def test_unknown_travel_type(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 5, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.')}
     with self.assertRaises(exceptions.UnknownTravelType):
         result = TourSortingApi().parse_data(initial_dataset)
         print(result[0])
示例#3
0
 def test_invalid_dataset(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.'),
         ('Barcelona', 'airport bus', 1, '', '')}
     with self.assertRaises(exceptions.InvalidBoardingCardData):
         TourSortingApi().parse_data(initial_dataset)
示例#4
0
 def test_broken_chain(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.'),
         ('Barcelona', 'Warsaw', 'airport bus', 1, '', '')}
     with self.assertRaises(exceptions.BrokenChainException):
         TourSortingApi().parse_data(initial_dataset)
示例#5
0
 def test_correct_data(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.'),
         ('Barcelona', 'Gerona', 'airport bus', 1, '', ''),
         ('Madrid', 'Barcelona', '78A', 0, 'seat 45B', ''),
         ('Gerona', 'Stockholm', 'SK455', 2, 'Gate 45B, seat 3A',
          'Baggage drop at ticket counter 344.'),
     }
     sorted_data = TourSortingApi().parse_data(initial_dataset)
     self.assertEqual(sorted_data[0].travel_start, 'Madrid')
     self.assertEqual(sorted_data[-1].travel_dest, 'New York')
示例#6
0
def main():
    # unordered set of sample data. Remember to keep the order of the data!
    initial_dataset = {
        ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
         'Baggage will be automatically transferred from your last leg.'),
        ('Barcelona', 'Gerona', 'airport bus', 1, '', ''),
        ('Madrid', 'Barcelona', '78A', 0, 'seat 45B', ''),
        ('Gerona', 'Stockholm', 'SK455', 2, 'Gate 45B, seat 3A',
         'Baggage drop at ticket counter 344.'),
    }

    for obj in TourSortingApi().parse_data(initial_dataset):
        print(obj)
    print('You have arrived at your final destination.')
示例#7
0
 def test_empty_dataset(self):
     with self.assertRaises(exceptions.EmptySetException):
         TourSortingApi().parse_data(set())
示例#8
0
 def test_correct_data_one_element(self):
     initial_dataset = {
         ('Stockholm', 'New York', 'SK22', 2, 'Gate 22, seat 7B',
          'Baggage will be automatically transferred from your last leg.')}
     sorted_data = TourSortingApi().parse_data(initial_dataset)
     self.assertEqual(len(sorted_data), 1)
示例#9
0
 def test_invalid_dataset_type_2(self):
     initial_dataset = ['Surely this is not a correct format']
     with self.assertRaises(exceptions.InvalidBoardingCardData):
         TourSortingApi().parse_data(initial_dataset)
示例#10
0
 def test_invalid_dataset_type(self):
     initial_dataset = {3, 32, 4}
     with self.assertRaises(exceptions.InvalidBoardingCardData):
         TourSortingApi().parse_data(initial_dataset)