[IMP] payment(_*): Remove dependency to AccountTestCommon

l10n runbot builds are all failing when running at least one test depending of AccountTestCommon because it:
- doesn't create a sandboxed testing environnement to manage the multi-currency, multi-company, the default company's currency, the exchange rates...
- doesn't setup a testing user then all tests are done using the superuser.
- doesn't provide a fully setup chart of accounts: exchange difference journal is not set, accounts have bad types, etc...
- is run sometimes at-install.

--task: 2296213
This commit is contained in:
Laurent Smet
2020-07-16 07:25:52 +00:00
parent d421934ff8
commit 85e187ebb5
10 changed files with 92 additions and 81 deletions
+16 -16
View File
@@ -1,19 +1,19 @@
# -*- coding: utf-8 -*-
from odoo.addons.account.tests.common import AccountTestCommon
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
class PaymentAcquirerCommon(AccountTestCommon):
class PaymentAcquirerCommon(AccountTestInvoicingCommon):
def setUp(self):
super(PaymentAcquirerCommon, self).setUp()
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
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
+19 -18
View File
@@ -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',
+6 -5
View File
@@ -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',
@@ -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',
@@ -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',
+7 -4
View File
@@ -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',
+15 -14
View File
@@ -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')
@@ -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',
+5 -4
View File
@@ -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',
+8 -7
View File
@@ -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,
})