mirror of
https://github.com/pyro2927/SouthwestCheckin.git
synced 2025-12-30 14:53:13 +00:00
Adding some tests
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
*.swp
|
||||||
|
.cache/
|
||||||
17
checkin_test.py
Normal file
17
checkin_test.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import pytest
|
||||||
|
import checkin
|
||||||
|
import requests_mock
|
||||||
|
from datetime import datetime
|
||||||
|
from pytz import timezone
|
||||||
|
|
||||||
|
@requests_mock.Mocker()
|
||||||
|
def test_checkin(m):
|
||||||
|
m.register_uri('GET', '/api/mobile-misc/v1/mobile-misc/page/view-reservation/XXXX?first-name=John&last-name=Smith', text=open('fixtures/view-reservation.json', 'r').read())
|
||||||
|
m.register_uri('GET', '/api/mobile-air-operations/v1/mobile-air-operations/page/check-in/XXXX?first-name=John&last-name=Smith', text=open('fixtures/checkin-get.json', 'r').read())
|
||||||
|
m.register_uri('POST', '/api/mobile-air-operations/v1/mobile-air-operations/page/check-in', text=open('fixtures/checkin-post.json', 'r').read())
|
||||||
|
assert checkin.auto_checkin('XXXX', 'John', 'Smith') == None
|
||||||
|
|
||||||
|
def test_timzone_localization():
|
||||||
|
tz = timezone('America/Los_Angeles')
|
||||||
|
date = tz.localize(datetime.strptime('2018-01-01 13:00', '%Y-%m-%d %H:%M'))
|
||||||
|
assert date.strftime('%z') == '-0800'
|
||||||
64
fixtures/checkin-get.json
Normal file
64
fixtures/checkin-get.json
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"checkInSessionToken": "",
|
||||||
|
"checkInViewReservationPage": {
|
||||||
|
"_links": {
|
||||||
|
"checkIn": {
|
||||||
|
"body": {
|
||||||
|
"checkInSessionToken": "",
|
||||||
|
"firstName": "John",
|
||||||
|
"lastName": "Smith",
|
||||||
|
"recordLocator": "XXXX"
|
||||||
|
},
|
||||||
|
"href": "/v1/mobile-air-operations/page/check-in",
|
||||||
|
"method": "POST"
|
||||||
|
},
|
||||||
|
"travelDocuments": null
|
||||||
|
},
|
||||||
|
"_v1_infoNeededToCheckin": {
|
||||||
|
"body": {
|
||||||
|
"names": [
|
||||||
|
{
|
||||||
|
"firstName": "JOHN",
|
||||||
|
"lastName": "SMITH"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"href": "/v1/mobile/reservations/record-locator/XXXX/boarding-passes",
|
||||||
|
"method": "POST"
|
||||||
|
},
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"arrivalAirport": "LAX",
|
||||||
|
"arrivalTime": "15:10",
|
||||||
|
"dates": {
|
||||||
|
"first": "2018-01-01",
|
||||||
|
"second": null
|
||||||
|
},
|
||||||
|
"departureAirport": "SFO",
|
||||||
|
"departureDate": "2018-01-01",
|
||||||
|
"departureTime": "13:45",
|
||||||
|
"destinationDescription": "Los Angeles",
|
||||||
|
"flights": [
|
||||||
|
{
|
||||||
|
"departureDate": "Jan 01",
|
||||||
|
"destinationAirportCode": "LAX",
|
||||||
|
"destinationStationName": "Los Angeles",
|
||||||
|
"flightNumber": "1234",
|
||||||
|
"hasWifi": true,
|
||||||
|
"originAirportCode": "SFO"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hazmatCheckInDisclaimer": "By tapping 'Check in' you acknowledge that you understand the hazardous materials restrictions and penalties.",
|
||||||
|
"travelTime": "1h 25m"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hazmatText": "Federal law forbids the carriage of hazardous materials such as aerosols, fireworks, lithium batteries and flammable liquids aboard the aircraft in your checked or carryon baggage. E-cigarettes are not permitted in checked baggage and must be transported in carryon baggage only.",
|
||||||
|
"pnr": {
|
||||||
|
"confirmationNumber": "XXXX",
|
||||||
|
"passengers": [
|
||||||
|
"John Smith"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"prefillPassengerAPISDocuments": null
|
||||||
|
}
|
||||||
45
fixtures/checkin-post.json
Normal file
45
fixtures/checkin-post.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"checkInConfirmationPage": {
|
||||||
|
"_links": {
|
||||||
|
"boardingPasses": {
|
||||||
|
"body": {
|
||||||
|
"checkInSessionToken": "XXXX",
|
||||||
|
"firstName": "JOHN",
|
||||||
|
"lastName": "SMITH",
|
||||||
|
"recordLocator": "XXXX"
|
||||||
|
},
|
||||||
|
"href": "/v1/mobile-air-operations/page/check-in/view-boarding-pass",
|
||||||
|
"method": "POST"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_v1_infoNeededToViewBoardingPasses": {
|
||||||
|
"href": "/v1/mobile/record-locator/XXXX/mobile-boarding-passes",
|
||||||
|
"method": "GET",
|
||||||
|
"query": {
|
||||||
|
"first-name": "JOHN",
|
||||||
|
"last-name": "SMITH"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flights": [
|
||||||
|
{
|
||||||
|
"boundIndex": 0,
|
||||||
|
"flightNumber": "1234",
|
||||||
|
"gate": null,
|
||||||
|
"hasWifi": true,
|
||||||
|
"passengers": [
|
||||||
|
{
|
||||||
|
"boardingGroup": "A",
|
||||||
|
"boardingPosition": "31",
|
||||||
|
"checkedIn": true,
|
||||||
|
"confirmationNumber": "XXXX",
|
||||||
|
"hasPrecheck": true,
|
||||||
|
"mobileBoardingPassEligible": true,
|
||||||
|
"mobileBoardingPassIneligibilityErrorCode": "",
|
||||||
|
"name": "John Smith"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"travelTime": "1h 25m"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
114
fixtures/view-reservation.json
Normal file
114
fixtures/view-reservation.json
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
{
|
||||||
|
"viewReservationViewPage": {
|
||||||
|
"_links": {
|
||||||
|
"cancel": null,
|
||||||
|
"change": null,
|
||||||
|
"checkIn": null,
|
||||||
|
"checkInSessionToken": null,
|
||||||
|
"passportEmergencyContacts": null,
|
||||||
|
"viewBoardingPass": null,
|
||||||
|
"viewBoardingPositions": null,
|
||||||
|
"viewStandbyList": null
|
||||||
|
},
|
||||||
|
"_v1_infoNeededToAddCompanion": null,
|
||||||
|
"_v1_infoNeededToCancel": {
|
||||||
|
"href": "/v1/mobile/reservations/record-locator/XXXX",
|
||||||
|
"method": "GET",
|
||||||
|
"query": {
|
||||||
|
"action": "CANCEL",
|
||||||
|
"first-name": "John",
|
||||||
|
"last-name": "Smith"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_v1_infoNeededToChange": {
|
||||||
|
"href": "/v1/mobile/reservations/record-locator/XXXX",
|
||||||
|
"method": "GET",
|
||||||
|
"query": {
|
||||||
|
"action": "CHANGE",
|
||||||
|
"first-name": "John",
|
||||||
|
"last-name": "Smith"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bounds": [
|
||||||
|
{
|
||||||
|
"arrivalAirport": {
|
||||||
|
"code": "LAX",
|
||||||
|
"country": null,
|
||||||
|
"name": "Los Angeles",
|
||||||
|
"state": "CA"
|
||||||
|
},
|
||||||
|
"arrivalStatus": null,
|
||||||
|
"arrivalStatusType": null,
|
||||||
|
"arrivalTime": "15:10",
|
||||||
|
"boundType": "DEPARTING",
|
||||||
|
"departureAirport": {
|
||||||
|
"code": "SFO",
|
||||||
|
"country": null,
|
||||||
|
"name": "San Francisco",
|
||||||
|
"state": "CA"
|
||||||
|
},
|
||||||
|
"departureDate": "2018-01-01",
|
||||||
|
"departureStatus": null,
|
||||||
|
"departureStatusType": null,
|
||||||
|
"departureTime": "13:45",
|
||||||
|
"fareType": "Companion",
|
||||||
|
"flights": [
|
||||||
|
{
|
||||||
|
"number": "1234",
|
||||||
|
"wifiOnBoard": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isNextDayArrival": false,
|
||||||
|
"passengerTypeCounts": {
|
||||||
|
"adult": 1,
|
||||||
|
"senior": 0
|
||||||
|
},
|
||||||
|
"stops": [],
|
||||||
|
"travelTime": "1h 25m"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"checkInIneligibilityReason": null,
|
||||||
|
"companion": null,
|
||||||
|
"confirmationNumber": "XXXX",
|
||||||
|
"dates": {
|
||||||
|
"first": "2018-01-01",
|
||||||
|
"second": null
|
||||||
|
},
|
||||||
|
"destinationAirport": {
|
||||||
|
"code": "LAX",
|
||||||
|
"country": null,
|
||||||
|
"name": "Los Angeles",
|
||||||
|
"state": "CA"
|
||||||
|
},
|
||||||
|
"destinationDescription": "Los Angeles",
|
||||||
|
"hasAnyCancelledFlights": false,
|
||||||
|
"hasUnaccompaniedMinor": false,
|
||||||
|
"isCheckInEligible": false,
|
||||||
|
"isCheckedIn": false,
|
||||||
|
"isDynamicWaiver": false,
|
||||||
|
"isInternational": false,
|
||||||
|
"isNonRevPnr": false,
|
||||||
|
"originAirport": {
|
||||||
|
"code": "SFO",
|
||||||
|
"country": null,
|
||||||
|
"name": "San Francisco",
|
||||||
|
"state": "CA"
|
||||||
|
},
|
||||||
|
"pageHeader": "SFO - LAX",
|
||||||
|
"passengers": [
|
||||||
|
{
|
||||||
|
"accountNumber": "111111111",
|
||||||
|
"checkInIneligibilityReason": null,
|
||||||
|
"hasAnyEarlyBird": false,
|
||||||
|
"hasCompletePassportInfo": false,
|
||||||
|
"isCheckInEligible": false,
|
||||||
|
"isCheckedIn": false,
|
||||||
|
"isUnaccompaniedMinor": false,
|
||||||
|
"name": "John Smith",
|
||||||
|
"passengerReference": "2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shouldShowAddEarlyBirdButton": false,
|
||||||
|
"standbyFlight": null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
datetime
|
datetime
|
||||||
docopts
|
docopts
|
||||||
geopy
|
geopy
|
||||||
|
pytest
|
||||||
python-dateutil
|
python-dateutil
|
||||||
pytz
|
pytz
|
||||||
requests
|
requests
|
||||||
|
requests_mock
|
||||||
tzlocal
|
tzlocal
|
||||||
|
|||||||
Reference in New Issue
Block a user