def test_multi_passenger_check_in(self):
        fake_event = {
            'passengers': [
                {"firstName": "GEORGE", "lastName": "BUSH"},
                {"firstName": "LAURA", "lastName": "BUSH"},
            ],
            'confirmation_number': 'ABC123',
            'check_in_times': {
                'remaining': [],
                'next': '2017-05-12T08:55:00-05:00'
            },
            'email': '*****@*****.**'
        }

        responses.add(
            responses.POST,
            'https://mobile.southwest.com/api/extensions/v1/mobile/reservations/'
            'record-locator/ABC123/boarding-passes',
            json=util.load_fixture('check_in_success'),
            status=200
        )

        responses.add(
            responses.POST,
            'https://mobile.southwest.com/api/extensions/v1/mobile/record-locator/'
            'ABC123/operation-infos/mobile-boarding-pass/notifications',
            json=util.load_fixture('email_boarding_pass'),
            status=200
        )

        assert(check_in(fake_event, None))
Beispiel #2
0
    def test_old_format_check_in(self):
        fake_event = {
            'first_name': "GEORGE",
            'last_name': "BUSH",
            'confirmation_number': 'ABC123',
            'check_in_times': {
                'remaining': [],
                'next': '2017-05-12T08:55:00-05:00'
            },
            'email': '*****@*****.**'
        }

        responses.add(
            responses.POST,
            'https://api-extensions.southwest.com/v1/mobile/reservations/'
            'record-locator/ABC123/boarding-passes',
            json=util.load_fixture('check_in_success'),
            status=200)

        responses.add(
            responses.POST,
            'https://api-extensions.southwest.com/v1/mobile/record-locator/'
            'ABC123/operation-infos/mobile-boarding-pass/notifications',
            json=util.load_fixture('email_boarding_pass'),
            status=200)

        result = handler.check_in(fake_event, None)
Beispiel #3
0
 def test_get_check_in_times_with_expired(self):
     # The get_active_reservation fixture contains one flight leg which has already occurred
     fixture = util.load_fixture('get_active_reservation')
     r = swa.Reservation(fixture)
     assert r.get_check_in_times(expired=True) == [
         '2099-08-21T07:35:05-05:00', '1999-08-17T18:50:05-05:00'
     ]
Beispiel #4
0
    def test_schedule_multi_passenger_check_in(self, email_mock):
        expected = {
            'passengers': [
                {
                    "firstName": "GEORGE",
                    "lastName": "BUSH"
                },
                {
                    "firstName": "LAURA",
                    "lastName": "BUSH"
                },
            ],
            'confirmation_number':
            'ABC123',
            'check_in_times': {
                'remaining': ['2099-05-13T15:10:05-05:00'],
                'next': '2099-05-12T08:55:05-05:00'
            },
            'email':
            '*****@*****.**'
        }

        responses.add(
            responses.GET,
            'https://api-extensions.southwest.com/v1/mobile/reservations/record-locator/ABC123',
            json=util.load_fixture('get_multi_passenger_reservation'),
            status=200)

        result = handler.schedule_check_in(self.mock_event, None)
        assert result == expected
Beispiel #5
0
 def test_check_in_times_alternate_second(self):
     fixture = util.load_fixture('get_reservation')
     r = swa.Reservation(fixture)
     r.check_in_seconds = 42
     assert r.check_in_times == [
         '2099-08-21T07:35:42-05:00', '2099-08-17T18:50:42-05:00'
     ]
Beispiel #6
0
 def test_check_in_reservation_cancelled(self):
     responses.add(
         responses.POST,
         'https://api-extensions.southwest.com/v1/mobile/reservations/record-locator/ABC123/boarding-passes',
         json=util.load_fixture('check_in_reservation_cancelled'),
         status=404)
     with self.assertRaises(exceptions.ReservationCancelledError):
         result = swa.check_in(self.names, self.confirmation_number)
Beispiel #7
0
 def test_from_passenger_info(self):
     responses.add(
         responses.GET,
         'https://api-extensions.southwest.com/v1/mobile/reservations/record-locator/ABC123',
         json=util.load_fixture('get_reservation'),
         status=200)
     r = swa.Reservation.from_passenger_info("George", "Bush", "ABC123")
     assert isinstance(r, swa.Reservation)
Beispiel #8
0
 def test_check_in_success(self):
     responses.add(
         responses.POST,
         'https://api-extensions.southwest.com/v1/mobile/reservations/record-locator/ABC123/boarding-passes',
         json=util.load_fixture('check_in_success'),
         status=200)
     result = swa.check_in(self.names, self.confirmation_number)
     assert result['passengerCheckInDocuments'][0]['passenger'][
         'firstName'] == "GEORGE"
     assert result['passengerCheckInDocuments'][0]['passenger'][
         'lastName'] == "BUSH"
Beispiel #9
0
 def test_multiple_passengers(self):
     fixture = util.load_fixture('get_multi_passenger_reservation')
     expected = [{
         "firstName": "GEORGE",
         "lastName": "BUSH"
     }, {
         "firstName": "LAURA",
         "lastName": "BUSH"
     }]
     r = swa.Reservation(fixture)
     assert r.passengers == expected
    def test_schedule_check_in_without_confirmation_email(self, email_mock):
        self.mock_event['send_confirmation_email'] = False
        responses.add(
            responses.GET,
            'https://mobile.southwest.com/api/extensions/v1/mobile/reservations/record-locator/ABC123',
            json=util.load_fixture('get_reservation'),
            status=200
        )

        schedule_check_in(self.mock_event, None)
        email_mock.assert_not_called()
Beispiel #11
0
    def test_not_last_check_in(self):
        fake_event = {
            'passengers': [
                {
                    "firstName": "GEORGE",
                    "lastName": "BUSH"
                },
                {
                    "firstName": "LAURA",
                    "lastName": "BUSH"
                },
            ],
            'confirmation_number':
            'ABC123',
            'check_in_times': {
                'remaining': ['2017-05-13T15:10:00-05:00'],
                'next': '2017-05-12T08:55:00-05:00'
            },
            'email':
            '*****@*****.**'
        }

        responses.add(
            responses.POST,
            'https://api-extensions.southwest.com/v1/mobile/reservations/'
            'record-locator/ABC123/boarding-passes',
            json=util.load_fixture('check_in_success'),
            status=200)

        responses.add(
            responses.POST,
            'https://api-extensions.southwest.com/v1/mobile/record-locator/'
            'ABC123/operation-infos/mobile-boarding-pass/notifications',
            json=util.load_fixture('email_boarding_pass'),
            status=200)

        try:
            result = handler.check_in(fake_event, None)
            assert False, "NotLastCheckIn exception was not raised"
        except exceptions.NotLastCheckIn:
            pass
Beispiel #12
0
    def test_find_new_reservation_email(self):
        test_subjects = [
            'fwd: George Bush\'s 12/25 Boston Logan trip (ABC123): Your reservation is confirmed.',
            'Fwd: George Bush\'s 12/25 Boston Logan trip (ABC123): Your reservation is confirmed.',
            'Fw: George Bush\'s 12/25 Boston Logan trip (ABC123): Your reservation is confirmed.',
            'George Bush\'s 12/25 Boston Logan trip (ABC123): Your change is confirmed.'
            'George Bush\'s 12/25 Detroit trip (ABC123)',
            'George Walker Bush\'s 12/25 Detroit trip (ABC123)',
            'George W Bush\'s 12/25 Detroit trip (ABC123)',
            'George W JR Bush\'s 12/25 Detroit trip (ABC123)',
            'George W. Bush\'s 12/25 Detroit trip (ABC123)',
            'George W Jr. Bush\'s 12/25 Detroit trip (ABC123)',
            'George W. Jr. Bush\'s 12/25 Detroit trip (ABC123)'
        ]

        for subject in test_subjects:
            e = FakeEmail(subject, 0, util.load_fixture('new_reservation_email'))
            expected = dict(first_name="George", last_name="Bush", confirmation_number="ABC123")
            result = mail.find_name_and_confirmation_number(e)
            assert result == expected, "Failed subject: {}".format(subject)
    def test_cancelled_check_in(self):
        fake_event = {
            'first_name': "GEORGE",
            'last_name': "BUSH",
            'confirmation_number': 'ABC123',
            'check_in_times': {
                'remaining': [],
                'next': '2017-05-12T08:55:00-05:00'
            },
            'email': '*****@*****.**'
        }

        responses.add(
            responses.POST,
            'https://api-extensions.southwest.com/v1/mobile/reservations/'
            'record-locator/ABC123/boarding-passes',
            json=util.load_fixture('check_in_reservation_cancelled'),
            status=404)

        assert (handler.check_in(fake_event, None) == False)
    def test_schedule_check_in(self, email_mock):
        expected = {
            'passengers': [
                {"firstName": "GEORGE", "lastName": "BUSH"}
            ],
            'confirmation_number': 'ABC123',
            'check_in_times': {
                'remaining': ['2099-08-21T07:35:05-05:00'],
                'next': '2099-08-17T18:50:05-05:00'
            },
            'email': '*****@*****.**'
        }

        responses.add(
            responses.GET,
            'https://mobile.southwest.com/api/extensions/v1/mobile/reservations/record-locator/ABC123',
            json=util.load_fixture('get_reservation'),
            status=200
        )

        result = schedule_check_in(self.mock_event, None)
        assert result == expected
Beispiel #15
0
 def test_confirmation_number(self):
     fixture = util.load_fixture('get_reservation')
     r = swa.Reservation(fixture)
     assert r.confirmation_number == "ABC123"
 def setUp(self):
     self.data = util.load_fixture('ses_email_notification')['mail']
Beispiel #17
0
 def test_check_in_times_no_expired(self):
     # The get_active_reservation fixture contains one flight leg which has already occurred
     fixture = util.load_fixture('get_active_reservation')
     r = swa.Reservation(fixture)
     assert r.check_in_times == ['2099-08-21T07:35:05-05:00']
Beispiel #18
0
 def test_check_in_times(self):
     fixture = util.load_fixture('get_reservation')
     r = swa.Reservation(fixture)
     assert r.check_in_times == [
         '2099-08-21T07:35:05-05:00', '2099-08-17T18:50:05-05:00'
     ]