Add test to check replaced field of replace party wizard
This commit is contained in:
@@ -13,6 +13,7 @@ from trytond.modules.account.tax import TaxableMixin
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.currency.tests import create_currency
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.transaction import Transaction, inactive_records
|
||||
@@ -167,7 +168,8 @@ def close_fiscalyear(fiscalyear):
|
||||
|
||||
|
||||
class AccountTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Account module'
|
||||
module = 'account'
|
||||
maxDiff = None
|
||||
|
||||
@@ -9,6 +9,7 @@ from trytond.modules.account_invoice.exceptions import (
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin)
|
||||
from trytond.modules.currency.tests import create_currency
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
@@ -35,7 +36,8 @@ def set_invoice_sequences(fiscalyear):
|
||||
|
||||
|
||||
class AccountInvoiceTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test AccountInvoice module'
|
||||
module = 'account_invoice'
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountPaymentTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Account Payment module'
|
||||
module = 'account_payment'
|
||||
extras = ['account_invoice', 'account_statement', 'account_statement_rule']
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountPaymentBraintreeTestCase(ModuleTestCase):
|
||||
class AccountPaymentBraintreeTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Account Payment Braintree module'
|
||||
module = 'account_payment_braintree'
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from trytond.modules.account_payment_sepa.payment import CAMT054
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, create_company, set_company)
|
||||
from trytond.modules.currency.tests import create_currency
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.transaction import Transaction
|
||||
@@ -149,7 +150,8 @@ def validate_file(flavor, kind, xsd=None):
|
||||
schema.assertValid(sepa_xml)
|
||||
|
||||
|
||||
class AccountPaymentSepaTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
class AccountPaymentSepaTestCase(
|
||||
PartyCheckReplaceMixin, CompanyTestMixin, ModuleTestCase):
|
||||
'Test Account Payment SEPA module'
|
||||
module = 'account_payment_sepa'
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountPaymentStripeTestCase(ModuleTestCase):
|
||||
class AccountPaymentStripeTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Account Payment Stripe module'
|
||||
module = 'account_payment_stripe'
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.company.tests import CompanyTestMixin
|
||||
from trytond.modules.party.tests import PartyCheckEraseMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AccountStatementTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
class AccountStatementTestCase(
|
||||
CompanyTestMixin, PartyCheckEraseMixin, ModuleTestCase):
|
||||
'Test AccountStatement module'
|
||||
module = 'account_statement'
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@ except ImportError:
|
||||
from trytond.model.exceptions import SQLConstraintError
|
||||
from trytond.modules.bank.exceptions import InvalidBIC
|
||||
from trytond.modules.currency.tests import create_currency
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class BankTestCase(ModuleTestCase):
|
||||
class BankTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Bank module'
|
||||
module = 'bank'
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.modules.company.tests import create_company, set_company
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
@@ -35,7 +36,7 @@ def create_carrier(list_price=None, cost_price=None):
|
||||
return carrier
|
||||
|
||||
|
||||
class CarrierTestCase(ModuleTestCase):
|
||||
class CarrierTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Carrier module'
|
||||
module = 'carrier'
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from decimal import Decimal
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
@@ -46,7 +47,8 @@ def create_plan(lines):
|
||||
|
||||
|
||||
class CommissionTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Commission module'
|
||||
module = 'commission'
|
||||
extras = ['sale', 'stock', 'account_invoice_stock']
|
||||
|
||||
@@ -10,7 +10,8 @@ from unittest.mock import patch
|
||||
from trytond.model import ModelStorage, ModelView
|
||||
from trytond.modules.company.model import CompanyMultiValueMixin
|
||||
from trytond.modules.currency.tests import add_currency_rate, create_currency
|
||||
from trytond.modules.party.tests import PartyCheckEraseMixin
|
||||
from trytond.modules.party.tests import (
|
||||
PartyCheckEraseMixin, PartyCheckReplaceMixin)
|
||||
from trytond.pool import Pool, isregisteredby
|
||||
from trytond.pyson import Eval, PYSONEncoder
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
@@ -152,7 +153,8 @@ class CompanyTestMixin:
|
||||
|
||||
|
||||
class CompanyTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Company module'
|
||||
module = 'company'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from .test_module import PartyCheckEraseMixin
|
||||
from .test_module import PartyCheckEraseMixin, PartyCheckReplaceMixin
|
||||
|
||||
__all__ = ['PartyCheckEraseMixin']
|
||||
__all__ = [PartyCheckEraseMixin, PartyCheckReplaceMixin]
|
||||
|
||||
@@ -16,6 +16,7 @@ from trytond.modules.party.party import (
|
||||
IDENTIFIER_TYPES, IDENTIFIER_VAT, replace_vat)
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.tools import is_instance_method
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
@@ -43,7 +44,34 @@ class PartyCheckEraseMixin:
|
||||
return party
|
||||
|
||||
|
||||
class PartyTestCase(PartyCheckEraseMixin, ModuleTestCase):
|
||||
class PartyCheckReplaceMixin:
|
||||
|
||||
@with_transaction()
|
||||
def test_check_replace_party(self):
|
||||
"Test fields to replace"
|
||||
pool = Pool()
|
||||
Replace = pool.get('party.replace', type='wizard')
|
||||
|
||||
for model_name, field_name in Replace.fields_to_replace():
|
||||
with self.subTest(model_name=model_name, field_name=field_name):
|
||||
Model = pool.get(model_name)
|
||||
field = getattr(Model, field_name)
|
||||
if field._type == 'reference':
|
||||
if isinstance(field.selection, (tuple, list)):
|
||||
self.assertIn('party.party', dict(field.selection))
|
||||
else:
|
||||
sel_func = getattr(Model, field.selection)
|
||||
instance_sel_func = is_instance_method(
|
||||
Model, field.selection)
|
||||
if not instance_sel_func:
|
||||
self.assertIn('party.party', dict(sel_func()))
|
||||
else:
|
||||
self.assertEqual(field._type, 'many2one')
|
||||
self.assertEqual(field.model_name, 'party.party')
|
||||
|
||||
|
||||
class PartyTestCase(
|
||||
PartyCheckEraseMixin, PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Party module'
|
||||
module = 'party'
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@ import datetime
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class ProjectTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Project module'
|
||||
module = 'project'
|
||||
|
||||
|
||||
@@ -7,13 +7,15 @@ from decimal import Decimal
|
||||
from trytond.modules.account.tests import create_chart
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class PurchaseTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Purchase module'
|
||||
module = 'purchase'
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
import datetime as dt
|
||||
|
||||
from trytond.modules.company.tests import create_company, set_company
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class PurchaseRequestTestCase(ModuleTestCase):
|
||||
class PurchaseRequestTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Purchase Request module'
|
||||
module = 'purchase_request'
|
||||
|
||||
|
||||
@@ -5,13 +5,15 @@ from decimal import Decimal
|
||||
from trytond.modules.account.tests import create_chart
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class SaleTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Sale module'
|
||||
module = 'sale'
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.company.tests import CompanyTestMixin
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleOpportunityTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
class SaleOpportunityTestCase(
|
||||
PartyCheckReplaceMixin, CompanyTestMixin, ModuleTestCase):
|
||||
'Test SaleOpportunity module'
|
||||
module = 'sale_opportunity'
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleSubscriptionTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Sale Subscription module'
|
||||
module = 'sale_subscription'
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleSupplyDropShipmentTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test SaleSupplyDropShipment module'
|
||||
module = 'sale_supply_drop_shipment'
|
||||
extras = ['sale_amendment', 'stock_split']
|
||||
|
||||
@@ -11,6 +11,7 @@ from dateutil.relativedelta import relativedelta
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.modules.company.tests import (
|
||||
CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, set_company)
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.modules.stock.exceptions import (
|
||||
LocationValidationError, MoveOriginWarning, PeriodCloseError,
|
||||
ProductStockWarning)
|
||||
@@ -20,7 +21,8 @@ from trytond.transaction import Transaction, check_access
|
||||
|
||||
|
||||
class StockTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
PartyCompanyCheckEraseMixin, PartyCheckReplaceMixin, CompanyTestMixin,
|
||||
ModuleTestCase):
|
||||
'Test Stock module'
|
||||
module = 'stock'
|
||||
longMessage = True
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.party.tests import PartyCheckReplaceMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class WebShopShopifyTestCase(ModuleTestCase):
|
||||
class WebShopShopifyTestCase(PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Web Shop Shopify module'
|
||||
module = 'web_shop_shopify'
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import trytond.config as config
|
||||
from trytond.modules.party.tests import PartyCheckEraseMixin
|
||||
from trytond.modules.party.tests import (
|
||||
PartyCheckEraseMixin, PartyCheckReplaceMixin)
|
||||
from trytond.modules.web_user import user as user_module
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
@@ -14,7 +15,8 @@ RESET_PASSWORD_URL = 'http://www.example.com/reset_password'
|
||||
FROM = 'tryton@example.com'
|
||||
|
||||
|
||||
class WebUserTestCase(PartyCheckEraseMixin, ModuleTestCase):
|
||||
class WebUserTestCase(
|
||||
PartyCheckEraseMixin, PartyCheckReplaceMixin, ModuleTestCase):
|
||||
'Test Web User module'
|
||||
module = 'web_user'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user