forked from alekseyl1992/yandex-checkout-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from yandex-money/release/v1.3.0
Release 1.3.0
- Loading branch information
Showing
34 changed files
with
2,428 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import unittest | ||
|
||
from yandex_checkout.domain.models.airline import Airline, Passenger, Leg | ||
|
||
|
||
class TestAirline(unittest.TestCase): | ||
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
|
||
from yandex_checkout.domain.models.amount import Amount | ||
from yandex_checkout.domain.models.currency import Currency | ||
|
||
|
||
class TestAmount(unittest.TestCase): | ||
def test_amount_cast(self): | ||
amount = Amount() | ||
amount.value = 0.1 | ||
amount.currency = Currency.RUB | ||
|
||
self.assertEqual({'value': 0.1, 'currency': Currency.RUB}, dict(amount)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import unittest | ||
|
||
from yandex_checkout.domain.common.base_object import BaseObject | ||
|
||
|
||
class MyBaseObject(BaseObject): | ||
__test = None | ||
__int_value = None | ||
__float_value = None | ||
__base_object = None | ||
__values_list = None | ||
__base_objects_list = None | ||
|
||
@property | ||
def test(self): | ||
return self.__test | ||
|
||
@test.setter | ||
def test(self, value): | ||
self.__test = value | ||
|
||
@property | ||
def int_value(self): | ||
return self.__int_value | ||
|
||
@int_value.setter | ||
def int_value(self, value): | ||
self.__int_value = value | ||
|
||
@property | ||
def float_value(self): | ||
return self.__float_value | ||
|
||
@float_value.setter | ||
def float_value(self, value): | ||
self.__float_value = value | ||
|
||
@property | ||
def base_object(self): | ||
return self.__base_object | ||
|
||
@base_object.setter | ||
def base_object(self, value): | ||
self.__base_object = MyBaseObject(value) | ||
|
||
@property | ||
def values_list(self): | ||
return self.__values_list | ||
|
||
@values_list.setter | ||
def values_list(self, value): | ||
self.__values_list = value | ||
|
||
@property | ||
def base_objects_list(self): | ||
return self.__base_objects_list | ||
|
||
@base_objects_list.setter | ||
def base_objects_list(self, value): | ||
self.__base_objects_list = [MyBaseObject(item) for item in value] | ||
|
||
|
||
class TestBaseObject(unittest.TestCase): | ||
def setUp(self): | ||
self.fixture_args = { | ||
'test': 'test', | ||
'int_value': 123, | ||
'float_value': 1.01, | ||
'base_object': { | ||
'test': 'test' | ||
}, | ||
'values_list': [1, 2, 3], | ||
'base_objects_list': [{'test': 'test'}, {'test': 'test'}, {'test': 'test'}] | ||
} | ||
|
||
def test_cas_to_dict_args(self): | ||
base_object = MyBaseObject(self.fixture_args) | ||
self.assertIsInstance(base_object.base_object, MyBaseObject) | ||
for item in base_object.base_objects_list: | ||
self.assertIsInstance(item, MyBaseObject) | ||
self.assertEqual(self.fixture_args, dict(base_object)) | ||
|
||
def test_cas_to_dict_kwargs(self): | ||
base_object = MyBaseObject(**self.fixture_args) | ||
self.assertIsInstance(base_object.base_object, MyBaseObject) | ||
for item in base_object.base_objects_list: | ||
self.assertIsInstance(item, MyBaseObject) | ||
self.assertEqual(self.fixture_args, dict(base_object)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import unittest | ||
|
||
from yandex_checkout.domain.models.currency import Currency | ||
from yandex_checkout.domain.request.capture_payment_builder import CapturePaymentBuilder | ||
from yandex_checkout.domain.request.capture_payment_request import CapturePaymentRequest | ||
|
||
|
||
class TestCapturePaymentBuilder(unittest.TestCase): | ||
def test_build_object(self): | ||
builder = CapturePaymentBuilder() | ||
builder \ | ||
.set_amount({'value': 0.1, 'currency': Currency.RUB}) \ | ||
.set_receipt({ | ||
'phone': '79990000000', 'email': '[email protected]', | ||
'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 = builder.build() | ||
|
||
self.assertIsInstance(request, CapturePaymentRequest) | ||
self.assertEqual( | ||
{ | ||
'amount': {'value': 0.1, 'currency': Currency.RUB}, | ||
'receipt': { | ||
'customer': {'phone': '79990000000', 'email': '[email protected]'}, | ||
'phone': '79990000000', | ||
'email': '[email protected]', | ||
'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 | ||
}, | ||
}, dict(request)) |
Oops, something went wrong.