def airline(self, value): if isinstance(value, dict): self.__airline = Airline(value) elif isinstance(value, Airline): self.__airline = value else: raise TypeError('Invalid airline type')
def test_setters_inline_data(self): airline = Airline() airline.booking_reference = '123123' airline.ticket_number = '5551238432721' airline.passengers = [{'first_name': 'Joe', 'last_name': 'Doe'}] airline.legs = [{ 'departure_airport': 'IVA', 'destination_airport': 'NYC', 'departure_date': '2017-01-02' }] self.assertEqual( { 'booking_reference': '123123', 'ticket_number': '5551238432721', 'passengers': [{ 'first_name': 'Joe', 'last_name': 'Doe' }], 'legs': [{ 'departure_airport': 'IVA', 'destination_airport': 'NYC', 'departure_date': '2017-01-02' }] }, dict(airline))
def test_setters_objects_data(self): airline = Airline() airline.booking_reference = '123123' airline.ticket_number = '5551238432721' joe = Passenger() joe.first_name = 'Joe' joe.last_name = 'Doe' airline.passengers = [joe] leg = Leg() leg.departure_airport = 'IVA' leg.destination_airport = 'NYC' leg.departure_date = '2017-01-02' airline.legs = [leg] self.assertEqual( { 'booking_reference': '123123', 'ticket_number': '5551238432721', 'passengers': [{ 'first_name': 'Joe', 'last_name': 'Doe' }], 'legs': [{ 'departure_airport': 'IVA', 'destination_airport': 'NYC', 'departure_date': '2017-01-02' }] }, dict(airline))
def test_capture_request_cast(self): request = CapturePaymentRequest() request.receipt = Receipt({ 'phone': '79990000000', 'email': '*****@*****.**', 'tax_system_code': 1, 'items': [{ "description": "Product 1", "quantity": 2.0, "amount": { "value": 250.0, "currency": Currency.RUB }, "vat_code": 2 }, { "description": "Product 2", "quantity": 1.0, "amount": { "value": 100.0, "currency": Currency.RUB }, "vat_code": 2 }] }) request.amount = Amount({'value': 0.1, 'currency': Currency.RUB}) request.airline = Airline({ "booking_reference": "IIIKRV", "passengers": [{ "first_name": "SERGEI", "last_name": "IVANOV" }], "legs": [{ "departure_airport": "LED", "destination_airport": "AMS", "departure_date": "2018-06-20" }] }) request.transfers.append( Transfer({ 'account_id': '79990000000', "amount": { "value": 100.01, "currency": Currency.RUB } })) self.assertEqual( { 'amount': { 'value': 0.1, 'currency': Currency.RUB }, 'receipt': { 'customer': { 'email': '*****@*****.**', 'phone': '79990000000' }, 'phone': '79990000000', 'email': '*****@*****.**', 'items': [{ "description": "Product 1", "quantity": 2.0, "amount": { "value": 250.0, "currency": Currency.RUB }, "vat_code": 2 }, { "description": "Product 2", "quantity": 1.0, "amount": { "value": 100.0, "currency": Currency.RUB }, "vat_code": 2 }], 'tax_system_code': 1, }, "airline": { "booking_reference": "IIIKRV", "passengers": [{ "first_name": "SERGEI", "last_name": "IVANOV" }], "legs": [{ "departure_airport": "LED", "destination_airport": "AMS", "departure_date": "2018-06-20" }] }, 'transfers': [{ 'account_id': '79990000000', "amount": { "value": 100.01, "currency": Currency.RUB } }] }, dict(request))
def test_request_cast(self): self.maxDiff = None request = PaymentRequest() request.amount = Amount({'value': 0.1, 'currency': Currency.RUB}) request.description = 'Test description' request.recipient = Recipient({ 'account_id': '213', 'gateway_id': '123' }) request.save_payment_method = True request.capture = False request.payment_method_data = PaymentDataWebmoney() request.receipt = Receipt({ 'phone': '79990000000', 'email': '*****@*****.**', 'tax_system_code': 1, 'items': [{ "description": "Product 1", "quantity": 2.0, "amount": { "value": 250.0, "currency": Currency.RUB }, "vat_code": 2 }, { "description": "Product 2", "quantity": 1.0, "amount": { "value": 100.0, "currency": Currency.RUB }, "vat_code": 2 }] }) request.airline = Airline({ "booking_reference": "IIIKRV", "passengers": [{ "first_name": "SERGEI", "last_name": "IVANOV" }], "legs": [{ "departure_airport": "LED", "destination_airport": "AMS", "departure_date": "2018-06-20" }] }) request.payment_method_id = '123' request.payment_token = '99091209012' request.confirmation = ConfirmationRedirect({ 'locale': 'ru_RU', 'return_url': 'return.url' }) request.client_ip = '192.0.0.0' request.metadata = {'key': 'value'} request.transfers.append( Transfer({ 'account_id': '79990000000', "amount": { "value": 100.01, "currency": Currency.RUB } })) self.assertEqual( { 'amount': { 'value': 0.1, 'currency': Currency.RUB }, 'recipient': { 'account_id': '213', 'gateway_id': '123' }, 'description': 'Test description', 'save_payment_method': True, 'capture': False, 'payment_method_data': { 'type': PaymentMethodType.WEBMONEY }, 'receipt': { 'customer': { 'email': '*****@*****.**', 'phone': '79990000000' }, 'phone': '79990000000', 'email': '*****@*****.**', 'tax_system_code': 1, 'items': [{ "description": "Product 1", "quantity": 2.0, "amount": { "value": 250.0, "currency": Currency.RUB }, "vat_code": 2 }, { "description": "Product 2", "quantity": 1.0, "amount": { "value": 100.0, "currency": Currency.RUB }, "vat_code": 2 }] }, 'payment_method_id': '123', 'payment_token': '99091209012', 'confirmation': { 'type': ConfirmationType.REDIRECT, 'locale': 'ru_RU', 'return_url': 'return.url' }, 'client_ip': '192.0.0.0', 'metadata': { 'key': 'value' }, "airline": { "booking_reference": "IIIKRV", "passengers": [{ "first_name": "SERGEI", "last_name": "IVANOV" }], "legs": [{ "departure_airport": "LED", "destination_airport": "AMS", "departure_date": "2018-06-20" }] }, 'transfers': [{ 'account_id': '79990000000', "amount": { "value": 100.01, "currency": Currency.RUB } }] }, dict(request))