Пример #1
0
    def test_from_london_to_paris(self, mockk):
        calculator = FlightCalculator('london', ['paris'])

        flights = list(calculator.process())
        self.assertEqual(1, len(flights))
        self.assertEqual([self.flight1], flights)
Пример #2
0
    def test_nonexistent_destination_city(self, mockk):
        with self.assertRaises(NoSuchCity) as ex_context:
            list(FlightCalculator('london', ['abra_cadabra']).process())

        self.assertEqual(ex_context.exception.args[0],
                         'abra_cadabra city not found')
Пример #3
0
    def test_empty_departure(self, mockk):
        with self.assertRaises(NoSuchCity) as ex_context:
            list(FlightCalculator('', ['paris']).process())

        self.assertEqual(ex_context.exception.args[0], ' city not found')
Пример #4
0
 def test_empty_destination(self, mockk):
     with self.assertRaises(NoDestinationCitiesProvided):
         list(FlightCalculator('london', []).process())
Пример #5
0
    def test_with_several_destination_cities(self, mockk):
        calculator = FlightCalculator('london', ['paris', 'berlin'])

        flights = list(calculator.process())
        self.assertEqual(2, len(flights))
        self.assertEqual([self.flight1, self.flight2], flights)