1- from bunq . sdk . model . generated . endpoint import ChatMessageText
2- from bunq . sdk . model . generated . endpoint import Payment
3- from bunq .sdk .model .generated . endpoint import PaymentChat
4- from bunq .sdk .model .generated . object_ import Amount
1+ from typing import List
2+
3+ from bunq .sdk .model .generated import endpoint
4+ from bunq .sdk .model .generated import object_
55from tests .bunq_test import BunqSdkTestCase
6- from tests .config import Config
76
87
98class TestPayment (BunqSdkTestCase ):
@@ -18,7 +17,8 @@ class TestPayment(BunqSdkTestCase):
1817 _PAYMENT_CURRENCY = 'EUR'
1918 _PAYMENT_DESCRIPTION = 'Python unit test'
2019 _PAYMENT_CHAT_TEXT_MESSAGE = 'send from python test'
21- _USER_ID = Config .get_user_id ()
20+
21+ _MAXIMUM_PAYMENT_IN_BATCH = 10
2222
2323 def test_payment_to_other_user (self ):
2424 """
@@ -28,8 +28,8 @@ def test_payment_to_other_user(self):
2828 without errors
2929 """
3030
31- Payment .create (
32- Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
31+ endpoint . Payment .create (
32+ object_ . Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
3333 self ._get_pointer_bravo (),
3434 self ._PAYMENT_DESCRIPTION
3535 )
@@ -42,8 +42,8 @@ def test_payment_to_other_account(self):
4242 without errors
4343 """
4444
45- Payment .create (
46- Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
45+ endpoint . Payment .create (
46+ object_ . Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
4747 self ._get_alias_second_account (),
4848 self ._PAYMENT_DESCRIPTION
4949 )
@@ -56,12 +56,53 @@ def test_payment_chat(self):
5656 without errors
5757 """
5858
59- payment_id = Payment .create (
60- Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
59+ payment_id = endpoint . Payment .create (
60+ object_ . Amount (self ._PAYMENT_AMOUNT_EUR , self ._PAYMENT_CURRENCY ),
6161 self ._get_pointer_bravo (),
6262 self ._PAYMENT_DESCRIPTION
6363 ).value
6464
65- chat_id = PaymentChat .create (payment_id ).value
65+ chat_id = endpoint .PaymentChat .create (payment_id ).value
66+
67+ endpoint .ChatMessageText .create (
68+ chat_id ,
69+ self ._PAYMENT_CHAT_TEXT_MESSAGE
70+ )
71+
72+ def test_payment_batch (self ):
73+ """
74+ """
75+
76+ response_create : endpoint .BunqResponseInt = \
77+ endpoint .PaymentBatch .create (
78+ self .__create_payment_list ()
79+ )
80+
81+ self .assertIsNotNone (response_create )
82+
83+ response_get : endpoint .BunqResponsePaymentBatch = \
84+ endpoint .PaymentBatch .get (response_create .value )
85+
86+ self .assertIsNotNone (response_get )
87+ self .assertFalse (response_get .value .is_all_field_none ())
88+
89+ def __create_payment_list (self ) -> List [endpoint .Payment ]:
90+ """
91+ :rtype: List[Payment]
92+ """
93+
94+ all_payment : List [endpoint .Payment ] = []
95+
96+ while len (all_payment ) < self ._MAXIMUM_PAYMENT_IN_BATCH :
97+ all_payment .append (
98+ endpoint .Payment (
99+ object_ .Amount (
100+ self ._PAYMENT_AMOUNT_EUR ,
101+ self ._PAYMENT_CURRENCY
102+ ),
103+ object_ .Pointer (self ._POINTER_EMAIL , self ._EMAIL_BRAVO ),
104+ self ._PAYMENT_DESCRIPTION
105+ )
106+ )
66107
67- ChatMessageText . create ( chat_id , self . _PAYMENT_CHAT_TEXT_MESSAGE )
108+ return all_payment
0 commit comments