Debian Codegraph @

addons/l10n_test_pos_qr_payment/tests/test_pos_qr_payment.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo.tests.common import tagged
4 from odoo.tools import mute_logger
5 from .common import TestPosQrCommon
6
7
8 @tagged('post_install_l10n', 'post_install', '-at_install')
9 class TestUiSEPA(TestPosQrCommon):
10
11 @classmethod
12 @TestPosQrCommon.setup_country('be')
13 def setUpClass(cls):
14 super().setUpClass()
15
16 # Set Bank Account on journal
17 cls.bank_account = cls.env['res.partner.bank'].create({
18 'acc_number': 'BE15001559627230',
19 'partner_id': cls.company_data['company'].partner_id.id,
20 })
21 cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
22
23 # Setup QR Payment method for SEPA
24 qr_payment = cls.env['pos.payment.method'].sudo().create({
25 'name': 'QR Code',
26 'journal_id': cls.company_data['default_journal_bank'].id,
27 'payment_method_type': "qr_code",
28 'qr_code_method': "sct_qr"
29 })
30 cls.main_pos_config.write({
31 'payment_method_ids': [(4, qr_payment.id)]
32 })
33
34 @mute_logger('odoo.http')
35 def test_01_pos_order_with_sepa_qr_payment_fail(self):
36 """ Test Point of Sale QR Payment flow with SEPA.
37 In this test the QR payment method is missing the required fields and will display an error message.
38 """
39
40 # Set non sepa bank account to make the test failed
41 self.bank_account.write({
42 'acc_number': 'SA4420000001234567891234',
43 })
44 self.main_pos_config.with_user(self.pos_user).open_ui()
45
46 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
47
48 def test_02_pos_order_with_sepa_qr_payment(self):
49 """ Test Point of Sale QR Payment flow with SEPA
50 """
51
52 # Set info that were wrong in test_01
53 self.bank_account.write({
54 'acc_number': 'BE15001559627230',
55 })
56 self.main_pos_config.with_user(self.pos_user).open_ui()
57
58 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")
59
60
61 @tagged('post_install_l10n', 'post_install', '-at_install')
62 class TestUiCH(TestPosQrCommon):
63
64 @classmethod
65 @TestPosQrCommon.setup_country('ch')
66 def setUpClass(cls):
67 super().setUpClass()
68
69 # Set required fields for Swiss QR bank account partner
70 cls.company_data['company'].partner_id.write({
71 'street': "Crab street, 11",
72 'city': "Crab City",
73 'zip': "4242",
74 })
75
76 # Set Bank Account on journal
77 cls.bank_account = cls.env['res.partner.bank'].create({
78 'acc_number': 'CH15 3881 5158 3845 3843 7',
79 'partner_id': cls.company_data['company'].partner_id.id,
80 })
81 cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
82
83 # Setup QR Payment method for Swiss QR
84 qr_payment = cls.env['pos.payment.method'].sudo().create({
85 'name': 'QR Code',
86 'journal_id': cls.company_data['default_journal_bank'].id,
87 'payment_method_type': "qr_code",
88 'qr_code_method': "ch_qr"
89 })
90 cls.main_pos_config.write({
91 'payment_method_ids': [(4, qr_payment.id)]
92 })
93
94 cls.env['res.partner'].create({
95 'name': 'AAA Partner Swiss',
96 'country_id': cls.env.ref('base.ch').id,
97 'street': "Crab street, 11",
98 'city': "Crab City",
99 'zip': "4242",
100 })
101
102 @mute_logger('odoo.http')
103 def test_01_pos_order_with_swiss_qr_payment_fail(self):
104 """ Test Point of Sale QR Payment flow with Swiss QR.
105 In this test the QR payment will fail as we are not selecting a swiss customer
106 """
107 self.main_pos_config.with_user(self.pos_user).open_ui()
108
109 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
110
111 def test_02_pos_order_with_swiss_qr_payment(self):
112 """ Test Point of Sale QR Payment flow with Swiss QR
113 We have to select a customer based in Switzerland or Lichtestein to use this payment method
114 """
115 self.main_pos_config.with_user(self.pos_user).open_ui()
116
117 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentSwiss', login="pos_user")
118
119
120 @tagged('post_install_l10n', 'post_install', '-at_install')
121 class TestUiHK(TestPosQrCommon):
122
123 @classmethod
124 def setup_armageddon_tax(cls, tax_name, company_data):
125 # Hong Kong doesn't have any tax, so this methods will throw errors if we don't return None
126 return None
127
128 @classmethod
129 @TestPosQrCommon.setup_country('hk')
130 def setUpClass(cls):
131 super().setUpClass()
132 cls.company_data['company'].partner_id.update({
133 'city': 'HK',
134 })
135
136 # Set Bank Account on journal
137 cls.bank_account = cls.env['res.partner.bank'].create({
138 'acc_number': '123-123456-123',
139 'partner_id': cls.company_data['company'].partner_id.id,
140 })
141 cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
142
143 # Setup QR Payment method for EMV(FPS)
144 qr_payment = cls.env['pos.payment.method'].sudo().create({
145 'name': 'QR Code',
146 'journal_id': cls.company_data['default_journal_bank'].id,
147 'payment_method_type': "qr_code",
148 'qr_code_method': "emv_qr"
149 })
150 cls.main_pos_config.write({
151 'payment_method_ids': [(4, qr_payment.id)]
152 })
153
154 @mute_logger('odoo.http')
155 def test_01_pos_order_with_fps_qr_payment_fail(self):
156 """ Test Point of Sale QR Payment flow with FPS.
157 In this test the QR payment method is missing the required fields and will display an error message.
158 """
159 self.main_pos_config.with_user(self.pos_user).open_ui()
160
161 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
162
163 def test_02_pos_order_with_emv_qr_payment(self):
164 """ Test Point of Sale QR Payment flow with FPS.
165 """
166
167 # Set missing info that were missing in test_01
168 self.bank_account.write({
169 'proxy_type': 'mobile',
170 'proxy_value': '+852-67891234',
171 'include_reference': True,
172 })
173
174 self.main_pos_config.with_user(self.pos_user).open_ui()
175
176 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")
177
178
179 @tagged('post_install_l10n', 'post_install', '-at_install')
180 class TestUIBR(TestPosQrCommon):
181
182 @classmethod
183 @TestPosQrCommon.setup_country('br')
184 def setUpClass(cls):
185 super().setUpClass()
186 cls.company_data['company'].partner_id.update({
187 'country_id': cls.env.ref('base.br').id,
188 'city': 'BR',
189 })
190
191 # Set Bank Account on journal
192 cls.bank_account = cls.env["res.partner.bank"].create({
193 "acc_number": "123456789012345678",
194 "partner_id": cls.company_data["company"].partner_id.id,
195 })
196 cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
197
198 # Setup QR Payment method for PIX
199 qr_payment = cls.env['pos.payment.method'].sudo().create({
200 'name': 'QR Code',
201 'journal_id': cls.company_data['default_journal_bank'].id,
202 'payment_method_type': "qr_code",
203 'qr_code_method': "emv_qr"
204 })
205 cls.main_pos_config.write({
206 'payment_method_ids': [(4, qr_payment.id)]
207 })
208
209 @mute_logger('odoo.http')
210 def test_01_pos_order_with_pix_qr_payment_fail(self):
211 """ Test Point of Sale QR Payment flow with PIX.
212 In this test the QR payment method is missing the required fields and will display an error message.
213 """
214 self.main_pos_config.with_user(self.pos_user).open_ui()
215
216 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
217
218 def test_02_pos_order_with_pix_qr_payment(self):
219 """ Test Point of Sale QR Payment flow with PIX
220 """
221
222 # Set missing info that were missing in test_01
223 self.bank_account.write({
224 "proxy_type": "br_random",
225 "proxy_value": "71d6c6e1-64ea-4a11-9560-a10870c40ca2",
226 "include_reference": True,
227 })
228
229 self.main_pos_config.with_user(self.pos_user).open_ui()
230
231 self.start_tour("/pos/ui/%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")