def test_reservation_accessibility_invalid_reservation_id(self): """ Test case for reservation with invalid accessibility requirements reservation id, reservation request fails. """ t = datetime.datetime.now() travel = self.testdata['travel_data_accessibility'] travel["travel"]["departureTimeEarliest"] = zulu.now().shift(days=(7 - t.weekday())). \ replace(hour=14, minute=00).isoformat() logging.info( "test_reservation_accessibility, availability request: %s" % travel) r_availability = lippuclient.availability_request( self.envdata['base_url'], headers=self.headers, payload=travel) logging.info( "test_reservation_accessibility, availability response: %s" % r_availability) self.assertEqual(r_availability.status_code, 200) self.assertGreater(len(r_availability.json()), 0) # Make reservation self.headers['X-Message-Id'] = str(uuid.uuid4()) travel_entitlement_id = r_availability.json( )['availability'][0]['travelEntitlementId'] reservation = { 'reservations': [{ 'travelEntitlementId': travel_entitlement_id, 'chosenAccessibilityReservationIds': [str(uuid.uuid4())], 'customerInfo': [self.testdata['customer_info']] }] } logging.info("Sending reservation %s" % reservation) r_reservation = lippuclient.reservation_request( self.envdata['base_url'], headers=self.headers, payload=reservation) logging.info( "test_reservation_accessibility, reservation response %s" % r_reservation.text) self.assertEqual(r_reservation.status_code, 404) # Test that reservation does not exits. self.headers['X-Message-Id'] = str(uuid.uuid4()) r = lippuclient.travel_entitlement_status( self.envdata['base_url'], headers=self.headers, travel_entitlement_id=travel_entitlement_id) logging.info( "test_reservation_accessibility, travel entitlement response %s" % r.text) self.assertEqual(r.status_code, 404)
def test_reservation_delete(self): """ Test case for reservation_delete, create reservation and then delete it. Cancelletion of transport reservation """ # Add reservation and test you can delete it with the case id travel = self.testdata['travel_data'] r_availability = lippuclient.availability_request( self.envdata['base_url'], headers=self.headers, payload=travel) logging.info("test_reservation_delete, availability response: %s" % r_availability) self.assertEqual(r_availability.status_code, 200) self.assertGreater(len(r_availability.json()), 0) # Make reservation self.headers['X-Message-Id'] = str(uuid.uuid4()) reservation = { 'reservations': [{ 'travelEntitlementId': r_availability.json()['availability'][0] ['travelEntitlementId'], 'customerInfo': [self.testdata['customer_info']] }] } logging.info("Sending reservation %s" % reservation) r_reservation = lippuclient.reservation_request( self.envdata['base_url'], headers=self.headers, payload=reservation) logging.info("test_reservation_delete, reservation response %s" % r_reservation.text) self.assertEqual(r_reservation.status_code, 200) self.headers['X-Message-Id'] = str(uuid.uuid4()) caseId = r_reservation.json()['caseId'] r_delete = lippuclient.reservation_delete(self.envdata['base_url'], headers=self.headers, reservation_id=caseId) self.assertEqual(r_delete.status_code, 200) # Test that already deleted reservation is deleted and could # not be deleted again. self.headers['X-Message-Id'] = str(uuid.uuid4()) r_delete2 = lippuclient.reservation_delete(self.envdata['base_url'], headers=self.headers, reservation_id=caseId) self.assertEqual(r_delete2.status_code, 404)
def test_reservation_invalid_reservation_ids(self): """ Test case for invalid reservation id, reservation request should fail. """ # Trip availaibility inquiry reservation = self.testdata['invalid_reservation_id'] logging.info("test_reservation, request data %s" % reservation) r = lippuclient.reservation_request(self.envdata['base_url'], headers=self.headers, payload=reservation) logging.info("test_reservation, response %s" % r.text) self.assertEqual(r.status_code, 404)
def test_reservation_extra_services_accessibility(self): """ Test case for reservation with extra services and accessibility requirements """ t = datetime.datetime.now() travel = self.testdata['travel_data_extra_services'] travel['passengers'][0]['accessibility'] = [{"title": "LOW-FLOOR"}] travel["travel"]["departureTimeEarliest"] = zulu.now().shift(days=(7 - t.weekday())). \ replace(hour=14, minute=00).isoformat() r_availability = lippuclient.availability_request( self.envdata['base_url'], headers=self.headers, payload=travel) logging.info( "test_reservation_extra_services_accessibility, availability response: %s" % r_availability) self.assertEqual(r_availability.status_code, 200) self.assertGreater(len(r_availability.json()['availability']), 0) # Make reservation self.headers['X-Message-Id'] = str(uuid.uuid4()) travel_entitlement_id = r_availability.json( )['availability'][0]['travelEntitlementId'] extra_service_id = r_availability.json()['availability'][0]\ ['applicableForPassengers'][0]['extraServices'][0]['extraServiceReservationId'] accessibility_id = r_availability.json()['availability'][0]\ ['applicableForPassengers'][0]['accessibility'][0]['accessibilityReservationId'] reservation = { 'reservations': [{ 'travelEntitlementId': travel_entitlement_id, 'chosenExtraReservationIds': [extra_service_id], 'chosenAccessibilityReservationIds': [accessibility_id], 'customerInfo': [self.testdata['customer_info']] }] } logging.info("Sending reservation %s" % reservation) r_reservation = lippuclient.reservation_request( self.envdata['base_url'], headers=self.headers, payload=reservation) logging.info("test_reservation_extra_services_accessibility, " "reservation response %s" % r_reservation.text) self.assertEqual(r_reservation.status_code, 200) self.assertNotEqual(r_reservation.json()['caseId'], None) self.assertNotEqual(r_reservation.json()['caseId'], '') self.assertNotEqual(r_reservation.json()['confirmedReservations'], None) self.assertEqual( r_reservation.json()['confirmedReservations'][0] ['travelEntitlementId'], travel_entitlement_id) caseId = r_reservation.json()['caseId'] # Test that reservation has the extra service and accessibility # requirements reserved in the reservation request. self.headers['X-Message-Id'] = str(uuid.uuid4()) r = lippuclient.travel_entitlement_status( self.envdata['base_url'], headers=self.headers, travel_entitlement_id=travel_entitlement_id) logging.info("test_reservation_extra_services_accessibility, " "travel entitlment response %s" % r_reservation.text) self.assertEqual(r.json()['travelEntitlementId'], travel_entitlement_id) self.assertEqual( r.json()['extraServices'][0]['extraServiceReservationId'], extra_service_id) self.assertEqual( r.json()['accessibility'][0]['accessibilityReservationId'], accessibility_id)
def test_reservation_do_not_include_accessibility(self): """ Test case for reservation with leaving out accessibility requirements that were in availability request. """ t = datetime.datetime.now() travel = self.testdata['travel_data_accessibility'] travel["travel"]["departureTimeEarliest"] = zulu.now().shift(days=(7 - t.weekday())). \ replace(hour=14, minute=00).isoformat() logging.info( "test_reservation_do_not_include_accessibility, availability request: %s" % travel) r_availability = lippuclient.availability_request( self.envdata['base_url'], headers=self.headers, payload=travel) logging.info( "test_reservation_do_not_include_accessibility, availability response: %s" % r_availability) self.assertEqual(r_availability.status_code, 200) self.assertGreater(len(r_availability.json()), 0) # Make reservation self.headers['X-Message-Id'] = str(uuid.uuid4()) travel_entitlement_id = r_availability.json( )['availability'][0]['travelEntitlementId'] accessibility_id = r_availability.json( )['availability'][0]['applicableForPassengers'][0]['accessibility'][0][ 'accessibilityReservationId'] reservation = { 'reservations': [{ 'travelEntitlementId': travel_entitlement_id, 'chosenAccessibilityReservationIds': [], 'customerInfo': [self.testdata['customer_info']] }] } logging.info("Sending reservation %s" % reservation) r_reservation = lippuclient.reservation_request( self.envdata['base_url'], headers=self.headers, payload=reservation) logging.info( "test_reservation_do_not_include_accessibility, reservation response %s" % r_reservation.text) self.assertEqual(r_reservation.status_code, 200) self.assertNotEqual(r_reservation.json()['caseId'], None) self.assertNotEqual(r_reservation.json()['caseId'], '') self.assertNotEqual(r_reservation.json()['confirmedReservations'], None) self.assertEqual( r_reservation.json()['confirmedReservations'][0] ['travelEntitlementId'], travel_entitlement_id) caseId = r_reservation.json()['caseId'] # Test that reservation does not have the accessibility features in # the reservation request. self.headers['X-Message-Id'] = str(uuid.uuid4()) r = lippuclient.travel_entitlement_status( self.envdata['base_url'], headers=self.headers, travel_entitlement_id=travel_entitlement_id) logging.info( "test_reservation_do_not_include_accessibility, travel entitlement response %s" % r_reservation.text) self.assertEqual(r.json()['travelEntitlementId'], travel_entitlement_id) self.assertEqual(r.json()['accessibility'], [])