diff options
| -rw-r--r-- | addons/payment/tests/common.py | 32 | ||||
| -rw-r--r-- | addons/payment_adyen/tests/test_adyen.py | 37 | ||||
| -rw-r--r-- | addons/payment_alipay/tests/test_alipay.py | 11 | ||||
| -rw-r--r-- | addons/payment_authorize/tests/test_authorize.py | 11 | ||||
| -rw-r--r-- | addons/payment_buckaroo/tests/test_buckaroo.py | 9 | ||||
| -rw-r--r-- | addons/payment_ingenico/tests/test_ogone.py | 11 | ||||
| -rw-r--r-- | addons/payment_paypal/tests/test_paypal.py | 29 | ||||
| -rw-r--r-- | addons/payment_payulatam/tests/test_payulatam.py | 9 | ||||
| -rw-r--r-- | addons/payment_sips/tests/test_sips.py | 9 | ||||
| -rw-r--r-- | addons/payment_stripe/tests/test_stripe.py | 15 |
10 files changed, 92 insertions, 81 deletions
diff --git a/addons/payment/tests/common.py b/addons/payment/tests/common.py index 58e12439cfb..495069565e3 100644 --- a/addons/payment/tests/common.py +++ b/addons/payment/tests/common.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- +from odoo.addons.account.tests.common import AccountTestInvoicingCommon -from odoo.addons.account.tests.common import AccountTestCommon +class PaymentAcquirerCommon(AccountTestInvoicingCommon): -class PaymentAcquirerCommon(AccountTestCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) - def setUp(self): - super(PaymentAcquirerCommon, self).setUp() - - self.currency_euro = self.env['res.currency'].search([('name', '=', 'EUR')], limit=1) - self.country_belgium = self.env['res.country'].search([('code', 'like', 'BE')], limit=1) - self.country_france = self.env['res.country'].search([('code', 'like', 'FR')], limit=1) + cls.currency_euro = cls.env.ref('base.EUR') + cls.country_belgium = cls.env.ref('base.be') + cls.country_france = cls.env.ref('base.fr') # dict partner values - self.buyer_values = { + cls.buyer_values = { 'partner_name': 'Norbert Buyer', 'partner_lang': 'en_US', 'partner_email': 'norbert.buyer@example.com', @@ -21,8 +21,8 @@ class PaymentAcquirerCommon(AccountTestCommon): 'partner_phone': '0032 12 34 56 78', 'partner_city': 'Sin City', 'partner_zip': '1000', - 'partner_country': self.env['res.country'].browse(self.country_belgium.id), - 'partner_country_id': self.country_belgium.id, + 'partner_country': cls.country_belgium, + 'partner_country_id': cls.country_belgium.id, 'partner_country_name': 'Belgium', 'billing_partner_name': 'Norbert Buyer', 'billing_partner_commercial_company_name': 'Big Company', @@ -32,13 +32,13 @@ class PaymentAcquirerCommon(AccountTestCommon): 'billing_partner_phone': '0032 12 34 56 78', 'billing_partner_city': 'Sin City', 'billing_partner_zip': '1000', - 'billing_partner_country': self.env['res.country'].browse(self.country_belgium.id), - 'billing_partner_country_id': self.country_belgium.id, + 'billing_partner_country': cls.country_belgium, + 'billing_partner_country_id': cls.country_belgium.id, 'billing_partner_country_name': 'Belgium', } # test partner - self.buyer = self.env['res.partner'].create({ + cls.buyer = cls.env['res.partner'].create({ 'name': 'Norbert Buyer', 'lang': 'en_US', 'email': 'norbert.buyer@example.com', @@ -47,5 +47,5 @@ class PaymentAcquirerCommon(AccountTestCommon): 'phone': '0032 12 34 56 78', 'city': 'Sin City', 'zip': '1000', - 'country_id': self.country_belgium.id}) - self.buyer_id = self.buyer.id + 'country_id': cls.country_belgium.id}) + cls.buyer_id = cls.buyer.id diff --git a/addons/payment_adyen/tests/test_adyen.py b/addons/payment_adyen/tests/test_adyen.py index bb02532a06c..1d792ccc089 100644 --- a/addons/payment_adyen/tests/test_adyen.py +++ b/addons/payment_adyen/tests/test_adyen.py @@ -10,26 +10,27 @@ import odoo.tests class AdyenCommon(PaymentAcquirerCommon): - def setUp(self): - super(AdyenCommon, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) # some CC (always use expiration date 06 / 2016, cvc 737, cid 7373 (amex)) - self.amex = (('370000000000002', '7373')) - self.dinersclub = (('36006666333344', '737')) - self.discover = (('6011601160116611', '737'), ('644564456445644', '737')) - self.jcb = (('3530111333300000', '737')) - self.mastercard = (('5555444433331111', '737'), ('5555555555554444', '737')) - self.visa = (('4111 1111 1111 1111', '737'), ('4444333322221111', '737')) - self.mcdebit = (('5500000000000004', '737')) - self.visadebit = (('4400000000000008', '737')) - self.maestro = (('6731012345678906', '737')) - self.laser = (('630495060000000000', '737')) - self.hipercard = (('6062828888666688', '737')) - self.dsmastercard = (('521234567890 1234', '737', 'user', 'password')) - self.dsvisa = (('4212345678901237', '737', 'user', 'password')) - self.mistercash = (('6703444444444449', None, 'user', 'password')) - self.adyen = self.env.ref('payment.payment_acquirer_adyen') - self.adyen.write({ + cls.amex = (('370000000000002', '7373')) + cls.dinersclub = (('36006666333344', '737')) + cls.discover = (('6011601160116611', '737'), ('644564456445644', '737')) + cls.jcb = (('3530111333300000', '737')) + cls.mastercard = (('5555444433331111', '737'), ('5555555555554444', '737')) + cls.visa = (('4111 1111 1111 1111', '737'), ('4444333322221111', '737')) + cls.mcdebit = (('5500000000000004', '737')) + cls.visadebit = (('4400000000000008', '737')) + cls.maestro = (('6731012345678906', '737')) + cls.laser = (('630495060000000000', '737')) + cls.hipercard = (('6062828888666688', '737')) + cls.dsmastercard = (('521234567890 1234', '737', 'user', 'password')) + cls.dsvisa = (('4212345678901237', '737', 'user', 'password')) + cls.mistercash = (('6703444444444449', None, 'user', 'password')) + cls.adyen = cls.env.ref('payment.payment_acquirer_adyen') + cls.adyen.write({ 'adyen_merchant_account': 'dummy', 'adyen_skin_code': 'dummy', 'adyen_skin_hmac_key': 'dummy', diff --git a/addons/payment_alipay/tests/test_alipay.py b/addons/payment_alipay/tests/test_alipay.py index 51e8e22fbfb..b1dfd720118 100644 --- a/addons/payment_alipay/tests/test_alipay.py +++ b/addons/payment_alipay/tests/test_alipay.py @@ -14,15 +14,16 @@ from odoo.addons.payment_alipay.controllers.main import AlipayController @odoo.tests.tagged('post_install', '-at_install', 'external', '-standard') class AlipayTest(PaymentAcquirerCommon): - def setUp(self): - super(AlipayTest, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) - self.currency_yuan = self.env['res.currency'].search([('name', '=', 'CNY'), + cls.currency_yuan = cls.env['res.currency'].search([('name', '=', 'CNY'), '|', ('active', '=', True), ('active', '=', False)], limit=1) - self.alipay = self.env.ref('payment.payment_acquirer_alipay') - self.alipay.write({ + cls.alipay = cls.env.ref('payment.payment_acquirer_alipay') + cls.alipay.write({ 'alipay_merchant_partner_id': 'dummy', 'alipay_md5_signature_key': 'dummy', 'alipay_seller_email': 'dummy', diff --git a/addons/payment_authorize/tests/test_authorize.py b/addons/payment_authorize/tests/test_authorize.py index d5b3ce98ef5..af9eda6b8fc 100644 --- a/addons/payment_authorize/tests/test_authorize.py +++ b/addons/payment_authorize/tests/test_authorize.py @@ -14,13 +14,14 @@ from odoo.tools import mute_logger @odoo.tests.tagged('post_install', '-at_install') class AuthorizeCommon(PaymentAcquirerCommon): - def setUp(self): - super(AuthorizeCommon, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) # authorize only support USD in test environment - self.currency_usd = self.env['res.currency'].search([('name', '=', 'USD')], limit=1)[0] + cls.currency_usd = cls.env['res.currency'].search([('name', '=', 'USD')], limit=1)[0] # get the authorize account - self.authorize = self.env.ref('payment.payment_acquirer_authorize') - self.authorize.write({ + cls.authorize = cls.env.ref('payment.payment_acquirer_authorize') + cls.authorize.write({ 'authorize_login': 'dummy', 'authorize_transaction_key': 'dummy', 'authorize_signature_key': '00000000', diff --git a/addons/payment_buckaroo/tests/test_buckaroo.py b/addons/payment_buckaroo/tests/test_buckaroo.py index 926ac2cf059..c516b7796a4 100644 --- a/addons/payment_buckaroo/tests/test_buckaroo.py +++ b/addons/payment_buckaroo/tests/test_buckaroo.py @@ -13,11 +13,12 @@ from odoo.tools import mute_logger @odoo.tests.tagged('post_install', '-at_install', 'external', '-standard') class BuckarooCommon(PaymentAcquirerCommon): - def setUp(self): - super(BuckarooCommon, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) # get the buckaroo account - self.buckaroo = self.env.ref('payment.payment_acquirer_buckaroo') - self.buckaroo.write({ + cls.buckaroo = cls.env.ref('payment.payment_acquirer_buckaroo') + cls.buckaroo.write({ 'brq_websitekey': 'dummy', 'brq_secretkey': 'dummy', 'state': 'test', diff --git a/addons/payment_ingenico/tests/test_ogone.py b/addons/payment_ingenico/tests/test_ogone.py index 09a25896796..9a8f577451e 100644 --- a/addons/payment_ingenico/tests/test_ogone.py +++ b/addons/payment_ingenico/tests/test_ogone.py @@ -9,15 +9,18 @@ from odoo.addons.payment_ingenico.controllers.main import OgoneController from werkzeug import urls from odoo.tools import mute_logger +from odoo.tests import tagged +@tagged('post_install', '-at_install', 'external', '-standard') class OgonePayment(PaymentAcquirerCommon): - def setUp(self): - super(OgonePayment, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) - self.ogone = self.env.ref('payment.payment_acquirer_ogone') - self.ogone.write({ + cls.ogone = cls.env.ref('payment.payment_acquirer_ogone') + cls.ogone.write({ 'ogone_pspid': 'dummy', 'ogone_userid': 'dummy', 'ogone_password': 'dummy', diff --git a/addons/payment_paypal/tests/test_paypal.py b/addons/payment_paypal/tests/test_paypal.py index 96a1be89a65..a8d173c3ed1 100644 --- a/addons/payment_paypal/tests/test_paypal.py +++ b/addons/payment_paypal/tests/test_paypal.py @@ -14,26 +14,27 @@ from lxml import objectify class PaypalCommon(PaymentAcquirerCommon): - def setUp(self): - super(PaypalCommon, self).setUp() + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) - self.paypal = self.env.ref('payment.payment_acquirer_paypal') - self.paypal.write({ + cls.paypal = cls.env.ref('payment.payment_acquirer_paypal') + cls.paypal.write({ 'paypal_email_account': 'dummy', 'state': 'test', }) # some CC - self.amex = (('378282246310005', '123'), ('371449635398431', '123')) - self.amex_corporate = (('378734493671000', '123')) - self.autralian_bankcard = (('5610591081018250', '123')) - self.dinersclub = (('30569309025904', '123'), ('38520000023237', '123')) - self.discover = (('6011111111111117', '123'), ('6011000990139424', '123')) - self.jcb = (('3530111333300000', '123'), ('3566002020360505', '123')) - self.mastercard = (('5555555555554444', '123'), ('5105105105105100', '123')) - self.visa = (('4111111111111111', '123'), ('4012888888881881', '123'), ('4222222222222', '123')) - self.dankord_pbs = (('76009244561', '123'), ('5019717010103742', '123')) - self.switch_polo = (('6331101999990016', '123')) + cls.amex = (('378282246310005', '123'), ('371449635398431', '123')) + cls.amex_corporate = (('378734493671000', '123')) + cls.autralian_bankcard = (('5610591081018250', '123')) + cls.dinersclub = (('30569309025904', '123'), ('38520000023237', '123')) + cls.discover = (('6011111111111117', '123'), ('6011000990139424', '123')) + cls.jcb = (('3530111333300000', '123'), ('3566002020360505', '123')) + cls.mastercard = (('5555555555554444', '123'), ('5105105105105100', '123')) + cls.visa = (('4111111111111111', '123'), ('4012888888881881', '123'), ('4222222222222', '123')) + cls.dankord_pbs = (('76009244561', '123'), ('5019717010103742', '123')) + cls.switch_polo = (('6331101999990016', '123')) @tagged('post_install', '-at_install', 'external', '-standard') diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py index 063eccac584..710d7dabe41 100644 --- a/addons/payment_payulatam/tests/test_payulatam.py +++ b/addons/payment_payulatam/tests/test_payulatam.py @@ -9,10 +9,11 @@ from odoo.tests import tagged class PayUlatamCommon(PaymentAcquirerCommon): - def setUp(self): - super(PayUlatamCommon, self).setUp() - self.payulatam = self.env.ref('payment.payment_acquirer_payulatam') - self.payulatam.write({ + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + cls.payulatam = cls.env.ref('payment.payment_acquirer_payulatam') + cls.payulatam.write({ 'payulatam_account_id': 'dummy', 'payulatam_merchant_id': 'dummy', 'payulatam_api_key': 'dummy', diff --git a/addons/payment_sips/tests/test_sips.py b/addons/payment_sips/tests/test_sips.py index 3ab711f9eb1..3b0bd2279e4 100644 --- a/addons/payment_sips/tests/test_sips.py +++ b/addons/payment_sips/tests/test_sips.py @@ -6,10 +6,11 @@ from odoo.addons.payment.tests.common import PaymentAcquirerCommon @tagged('post_install', '-at_install', '-standard', 'external') class SipsTest(PaymentAcquirerCommon): - def setUp(self): - super().setUp() - self.sips = self.env.ref('payment.payment_acquirer_sips') - self.sips.write({ + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + cls.sips = cls.env.ref('payment.payment_acquirer_sips') + cls.sips.write({ 'state': 'test', 'sips_merchant_id': 'dummy_mid', 'sips_secret': 'dummy_secret', diff --git a/addons/payment_stripe/tests/test_stripe.py b/addons/payment_stripe/tests/test_stripe.py index ed7fd19b462..92b3a8d1be7 100644 --- a/addons/payment_stripe/tests/test_stripe.py +++ b/addons/payment_stripe/tests/test_stripe.py @@ -7,20 +7,21 @@ from odoo.tools import mute_logger class StripeCommon(PaymentAcquirerCommon): - def setUp(self): - super(StripeCommon, self).setUp() - self.stripe = self.env.ref('payment.payment_acquirer_stripe') - self.stripe.write({ + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + cls.stripe = cls.env.ref('payment.payment_acquirer_stripe') + cls.stripe.write({ 'stripe_secret_key': 'sk_test_KJtHgNwt2KS3xM7QJPr4O5E8', 'stripe_publishable_key': 'pk_test_QSPnimmb4ZhtkEy3Uhdm4S6J', 'state': 'test', }) - self.token = self.env['payment.token'].create({ + cls.token = cls.env['payment.token'].create({ 'name': 'Test Card', - 'acquirer_id': self.stripe.id, + 'acquirer_id': cls.stripe.id, 'acquirer_ref': 'cus_G27S7FqQ2w3fuH', 'stripe_payment_method': 'pm_1FW3DdAlCFm536g8eQoSCejY', - 'partner_id': self.buyer.id, + 'partner_id': cls.buyer.id, 'verified': True, }) |
