Beispiel #1
0
    def test_list_flight_endpoint(self):
        flights = FlightFactory.create_batch(3)
        response = self.client().get(self.make_url('/flight/'),
                                     headers=self.headers())
        response_json = self.decode_from_json_string(
            response.data.decode('utf-8'))
        payload = response_json['payload']

        self.assert200(response)
        self.assertEqual(len(payload['flights']), 3)
        self.assertJSONKeysPresent(payload['flights'][0], 'flightCode',
                                   'fromLocation')
        self.assertEqual(payload['flights'][0]['flightCode'],
                         flights[0].flight_code)
        self.assertEqual(payload['flights'][0]['fromLocation'],
                         flights[0].from_location)
        self.assertEqual(payload['flights'][0]['toLocation'],
                         flights[0].to_location)
Beispiel #2
0
    def test_get_flight_by_location_and_date_endpoint(self):
        flight = FlightFactory.create_batch(5)
        response = self.client().get(self.make_url('/flight/{}/{}/{}/'.format(
            flight[2].from_location, flight[2].to_location,
            flight[2].departure_date)),
                                     headers=self.headers())
        response_json = self.decode_from_json_string(
            response.data.decode('utf-8'))
        payload = response_json['payload']

        self.assert200(response)
        self.assertJSONKeysPresent(payload['flights'][2], 'flightCode',
                                   'fromLocation')
        self.assertEqual(payload['flights'][2]['flightCode'],
                         flight[2].flight_code)
        self.assertEqual(payload['flights'][2]['fromLocation'],
                         flight[2].from_location)
        self.assertEqual(payload['flights'][2]['toLocation'],
                         flight[2].to_location)