Skip to content

Commit

Permalink
Merge pull request #37 from yandex-money/release/v1.3.0
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
tonchik-tm authored Aug 16, 2019
2 parents 5c0a589 + 44c1b94 commit 56d0840
Show file tree
Hide file tree
Showing 34 changed files with 2,428 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.3.0 от 16.08.2019
* Добавлен платежный метод WeChat
* Обновлены тесты

### 1.2.0 от 18.07.2019
* Добавлены новые поля для 54 ФЗ
* Добавлена ручка receipts
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="yandex_checkout",
version="1.2.0",
version="1.3.0",
description="Yandex Checkout SDK Python Library",
long_description=long_description,
author="Yandex.Money",
Expand Down
80 changes: 80 additions & 0 deletions test/unit/test_airline.py
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))
13 changes: 13 additions & 0 deletions test/unit/test_amount.py
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))
88 changes: 88 additions & 0 deletions test/unit/test_base_object.py
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))
70 changes: 70 additions & 0 deletions test/unit/test_capture_payment_builder.py
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))
Loading

0 comments on commit 56d0840

Please sign in to comment.