Beispiel #1
0
    def test_update_flight_endpoint(self):
        flight = FlightFactory.create()
        data = {
            'flightCode': 'ARK2102',
            'status': 'TakenOff',
            'fromLocation': 'ABV',
            'toLocation': 'LOS',
            'depatureTime': str(datetime.now()),
            'arrivalTime': str(datetime.now() + timedelta(hours=1)),
            'price': 35000,
            'noOfSeats': 150
        }
        response = self.client().put(self.make_url('/flight/{}/'.format(
            flight.id)),
                                     data=self.encode_to_json_string(data),
                                     headers=self.headers())
        response_json = self.decode_from_json_string(
            response.data.decode('utf-8'))
        payload = response_json['payload']

        self.assert200(response)
        self.assertEqual(payload['flight']['flightCode'], data['flightCode'])
        self.assertEqual(payload['flight']['fromLocation'],
                         data['fromLocation'])
        self.assertEqual(payload['flight']['toLocation'], data['toLocation'])
Beispiel #2
0
    def test_delete_flight_endpoint(self):
        flight = FlightFactory.create()
        response = self.client().delete(self.make_url('/flight/{}/'.format(
            flight.id)),
                                        headers=self.headers())
        response_json = self.decode_from_json_string(
            response.data.decode('utf-8'))
        payload = response_json['payload']

        self.assert200(response)
        self.assertEqual(payload['status'], "success")
Beispiel #3
0
    def test_get_specific_flight_endpoint(self):
        flight = FlightFactory.create()
        response = self.client().get(self.make_url('/flight/{}/'.format(
            flight.id)),
                                     headers=self.headers())
        response_json = self.decode_from_json_string(
            response.data.decode('utf-8'))
        payload = response_json['payload']
        print(payload)

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