diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index be856bcdb38..7c5b0e99208 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -5,7 +5,7 @@ import unittest import frappe -from frappe.test_runner import make_test_records +from frappe.tests.utils import make_test_records from frappe.utils import nowdate from erpnext.accounts.doctype.account.account import ( diff --git a/erpnext/accounts/doctype/account_closing_balance/test_account_closing_balance.py b/erpnext/accounts/doctype/account_closing_balance/test_account_closing_balance.py index fc42677062e..c24fb115d0a 100644 --- a/erpnext/accounts/doctype/account_closing_balance/test_account_closing_balance.py +++ b/erpnext/accounts/doctype/account_closing_balance/test_account_closing_balance.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestAccountClosingBalance(FrappeTestCase): +class UnitTestAccountClosingBalance(UnitTestCase): + """ + Unit tests for AccountClosingBalance. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAccountClosingBalance(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py index 3813052187a..4f3808f157a 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py @@ -4,7 +4,7 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, today from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import ( @@ -15,7 +15,7 @@ from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_pay from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestBankReconciliationTool(AccountsTestMixin, FrappeTestCase): +class TestBankReconciliationTool(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/doctype/bank_transaction/test_auto_match_party.py b/erpnext/accounts/doctype/bank_transaction/test_auto_match_party.py index 36ef1fca074..db87a72aba4 100644 --- a/erpnext/accounts/doctype/bank_transaction/test_auto_match_party.py +++ b/erpnext/accounts/doctype/bank_transaction/test_auto_match_party.py @@ -2,13 +2,22 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import nowdate from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account -class TestAutoMatchParty(FrappeTestCase): +class UnitTestBankTransaction(UnitTestCase): + """ + Unit tests for BankTransaction. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAutoMatchParty(IntegrationTestCase): @classmethod def setUpClass(cls): create_bank_account() diff --git a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py index 3181a097c6a..9f9fa349c37 100644 --- a/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/test_bank_transaction.py @@ -6,7 +6,7 @@ import json import frappe from frappe import utils from frappe.model.docstatus import DocStatus -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import ( get_linked_payments, @@ -21,7 +21,16 @@ from erpnext.tests.utils import if_lending_app_installed test_dependencies = ["Item", "Cost Center"] -class TestBankTransaction(FrappeTestCase): +class UnitTestBankTransaction(UnitTestCase): + """ + Unit tests for BankTransaction. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBankTransaction(IntegrationTestCase): def setUp(self): for dt in [ "Bank Transaction", diff --git a/erpnext/accounts/doctype/bisect_accounting_statements/test_bisect_accounting_statements.py b/erpnext/accounts/doctype/bisect_accounting_statements/test_bisect_accounting_statements.py index 56ecc94a18e..6c680c80183 100644 --- a/erpnext/accounts/doctype/bisect_accounting_statements/test_bisect_accounting_statements.py +++ b/erpnext/accounts/doctype/bisect_accounting_statements/test_bisect_accounting_statements.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestBisectAccountingStatements(FrappeTestCase): +class UnitTestBisectAccountingStatements(UnitTestCase): + """ + Unit tests for BisectAccountingStatements. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBisectAccountingStatements(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/bisect_nodes/test_bisect_nodes.py b/erpnext/accounts/doctype/bisect_nodes/test_bisect_nodes.py index 5399df139f1..e56c0769c71 100644 --- a/erpnext/accounts/doctype/bisect_nodes/test_bisect_nodes.py +++ b/erpnext/accounts/doctype/bisect_nodes/test_bisect_nodes.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestBisectNodes(FrappeTestCase): +class UnitTestBisectNodes(UnitTestCase): + """ + Unit tests for BisectNodes. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBisectNodes(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/dunning/test_dunning.py b/erpnext/accounts/doctype/dunning/test_dunning.py index 62a0c90046b..20bf1c462db 100644 --- a/erpnext/accounts/doctype/dunning/test_dunning.py +++ b/erpnext/accounts/doctype/dunning/test_dunning.py @@ -1,7 +1,7 @@ # Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, nowdate, today from erpnext import get_default_cost_center @@ -19,7 +19,16 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import ( test_dependencies = ["Company", "Cost Center"] -class TestDunning(FrappeTestCase): +class UnitTestDunning(UnitTestCase): + """ + Unit tests for Dunning. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDunning(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py index 51053f1f68c..b57df9e92f3 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/test_exchange_rate_revaluation.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, flt, today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -11,7 +11,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase): +class TestExchangeRateRevaluation(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_usd_receivable_account() @@ -35,7 +35,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase): company_doc.unrealized_exchange_gain_loss_account = company_doc.exchange_gain_loss_account company_doc.save() - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0}, ) @@ -88,7 +88,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase): )[0] self.assertEqual(acc_balance.balance, 8500.0) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0}, ) @@ -158,7 +158,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase): self.assertEqual(acc_balance.balance, 0.0) self.assertEqual(acc_balance.balance_in_account_currency, 0.0) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0}, ) @@ -247,7 +247,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase): self.assertEqual(flt(acc_balance.balance, precision), 0.0) self.assertEqual(flt(acc_balance.balance_in_account_currency, precision), 0.0) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0}, ) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 3d4b182d52d..87e335ef779 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -1,10 +1,8 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt - -import unittest - import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.tests.utils import change_settings from frappe.utils import flt, nowdate @@ -13,8 +11,19 @@ from erpnext.accounts.doctype.journal_entry.journal_entry import StockAccountInv from erpnext.exceptions import InvalidAccountCurrency -class TestJournalEntry(unittest.TestCase): - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) +class UnitTestJournalEntry(UnitTestCase): + """ + Unit tests for JournalEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestJournalEntry(IntegrationTestCase): + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_journal_entry_with_against_jv(self): jv_invoice = frappe.copy_doc(test_records[2]) base_jv = frappe.copy_doc(test_records[0]) diff --git a/erpnext/accounts/doctype/ledger_health/test_ledger_health.py b/erpnext/accounts/doctype/ledger_health/test_ledger_health.py index d35b39d9ea1..0eec86ccc0f 100644 --- a/erpnext/accounts/doctype/ledger_health/test_ledger_health.py +++ b/erpnext/accounts/doctype/ledger_health/test_ledger_health.py @@ -3,14 +3,14 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import nowdate from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.accounts.utils import run_ledger_health_checks -class TestLedgerHealth(AccountsTestMixin, FrappeTestCase): +class TestLedgerHealth(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/doctype/ledger_health_monitor/test_ledger_health_monitor.py b/erpnext/accounts/doctype/ledger_health_monitor/test_ledger_health_monitor.py index e0ba4435b82..a5aacde416e 100644 --- a/erpnext/accounts/doctype/ledger_health_monitor/test_ledger_health_monitor.py +++ b/erpnext/accounts/doctype/ledger_health_monitor/test_ledger_health_monitor.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestLedgerHealthMonitor(FrappeTestCase): +class UnitTestLedgerHealthMonitor(UnitTestCase): + """ + Unit tests for LedgerHealthMonitor. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestLedgerHealthMonitor(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py index 378fbded863..ead36abd38a 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import ( create_dimension, @@ -15,7 +15,16 @@ from erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_crea test_dependencies = ["Customer", "Supplier", "Accounting Dimension"] -class TestOpeningInvoiceCreationTool(FrappeTestCase): +class UnitTestOpeningInvoiceCreationTool(UnitTestCase): + """ + Unit tests for OpeningInvoiceCreationTool. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestOpeningInvoiceCreationTool(IntegrationTestCase): @classmethod def setUpClass(self): if not frappe.db.exists("Company", "_Test Opening Invoice Company"): diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 80efa15f123..6b347c0e41c 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -4,7 +4,7 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, flt, nowdate from erpnext.accounts.doctype.account.test_account import create_account @@ -28,7 +28,16 @@ from erpnext.setup.doctype.employee.test_employee import make_employee test_dependencies = ["Item"] -class TestPaymentEntry(FrappeTestCase): +class UnitTestPaymentEntry(UnitTestCase): + """ + Unit tests for PaymentEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPaymentEntry(IntegrationTestCase): def tearDown(self): frappe.db.rollback() @@ -383,7 +392,7 @@ class TestPaymentEntry(FrappeTestCase): self.assertEqual(si.payment_schedule[0].outstanding, 0) self.assertEqual(si.payment_schedule[0].discounted_amount, 50) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "allow_multi_currency_invoices_against_single_party_account": 1, @@ -1090,7 +1099,7 @@ class TestPaymentEntry(FrappeTestCase): } self.assertDictEqual(ref_details, expected_response) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "unlink_payment_on_cancellation_of_invoice": 1, @@ -1185,7 +1194,7 @@ class TestPaymentEntry(FrappeTestCase): si3.cancel() si3.delete() - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "unlink_payment_on_cancellation_of_invoice": 1, @@ -1791,7 +1800,7 @@ class TestPaymentEntry(FrappeTestCase): # 'Is Opening' should always be 'No' for normal advance payments self.assertEqual(gl_with_opening_set, []) - @change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1}) + @IntegrationTestCase.change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1}) def test_delete_linked_exchange_gain_loss_journal(self): from erpnext.accounts.doctype.account.test_account import create_account from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import ( diff --git a/erpnext/accounts/doctype/payment_ledger_entry/test_payment_ledger_entry.py b/erpnext/accounts/doctype/payment_ledger_entry/test_payment_ledger_entry.py index 9a33a7ccf6d..13598735aef 100644 --- a/erpnext/accounts/doctype/payment_ledger_entry/test_payment_ledger_entry.py +++ b/erpnext/accounts/doctype/payment_ledger_entry/test_payment_ledger_entry.py @@ -3,7 +3,7 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import nowdate from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -13,7 +13,16 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde from erpnext.stock.doctype.item.test_item import create_item -class TestPaymentLedgerEntry(FrappeTestCase): +class UnitTestPaymentLedgerEntry(UnitTestCase): + """ + Unit tests for PaymentLedgerEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPaymentLedgerEntry(IntegrationTestCase): def setUp(self): self.ple = qb.DocType("Payment Ledger Entry") self.create_company() @@ -445,7 +454,7 @@ class TestPaymentLedgerEntry(FrappeTestCase): self.assertEqual(pl_entries_for_crnote[0], expected_values[0]) self.assertEqual(pl_entries_for_crnote[1], expected_values[1]) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1}, ) @@ -474,7 +483,7 @@ class TestPaymentLedgerEntry(FrappeTestCase): si.delete() self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1}, ) @@ -507,7 +516,7 @@ class TestPaymentLedgerEntry(FrappeTestCase): si.delete() self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "unlink_payment_on_cancellation_of_invoice": 1, diff --git a/erpnext/accounts/doctype/payment_order/test_payment_order.py b/erpnext/accounts/doctype/payment_order/test_payment_order.py index 7af096647ca..e98531bc54d 100644 --- a/erpnext/accounts/doctype/payment_order/test_payment_order.py +++ b/erpnext/accounts/doctype/payment_order/test_payment_order.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import getdate from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import ( @@ -17,7 +17,16 @@ from erpnext.accounts.doctype.payment_entry.payment_entry import ( from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice -class TestPaymentOrder(FrappeTestCase): +class UnitTestPaymentOrder(UnitTestCase): + """ + Unit tests for PaymentOrder. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPaymentOrder(IntegrationTestCase): def setUp(self): # generate and use a uniq hash identifier for 'Bank Account' and it's linked GL 'Account' to avoid validation error uniq_identifier = frappe.generate_hash(length=10) diff --git a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py index 883c638398c..74314e129c0 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py @@ -4,7 +4,7 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, add_years, flt, getdate, nowdate, today from erpnext import get_default_cost_center @@ -20,7 +20,16 @@ from erpnext.stock.doctype.item.test_item import create_item test_dependencies = ["Item"] -class TestPaymentReconciliation(FrappeTestCase): +class UnitTestPaymentReconciliation(UnitTestCase): + """ + Unit tests for PaymentReconciliation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPaymentReconciliation(IntegrationTestCase): def setUp(self): self.create_company() self.create_item() @@ -1104,7 +1113,7 @@ class TestPaymentReconciliation(FrappeTestCase): payment_vouchers = [x.get("reference_name") for x in pr.get("payments")] self.assertCountEqual(payment_vouchers, [je2.name, pe2.name]) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "allow_multi_currency_invoices_against_single_party_account": 1, diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index 02f8e3b4e95..3b75e735f66 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -6,7 +6,7 @@ import unittest from unittest.mock import patch import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_terms_template from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request @@ -57,7 +57,16 @@ payment_method = [ ] -class TestPaymentRequest(FrappeTestCase): +class UnitTestPaymentRequest(UnitTestCase): + """ + Unit tests for PaymentRequest. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPaymentRequest(IntegrationTestCase): def setUp(self): for payment_gateway in payment_gateways: if not frappe.db.get_value("Payment Gateway", payment_gateway["gateway"], "name"): @@ -218,7 +227,7 @@ class TestPaymentRequest(FrappeTestCase): def test_payment_entry_against_purchase_invoice(self): si_usd = make_purchase_invoice( - customer="_Test Supplier USD", + supplier="_Test Supplier USD", debit_to="_Test Payable USD - _TC", currency="USD", conversion_rate=50, @@ -243,7 +252,7 @@ class TestPaymentRequest(FrappeTestCase): def test_multiple_payment_entry_against_purchase_invoice(self): purchase_invoice = make_purchase_invoice( - customer="_Test Supplier USD", + supplier="_Test Supplier USD", debit_to="_Test Payable USD - _TC", currency="USD", conversion_rate=50, @@ -483,7 +492,9 @@ class TestPaymentRequest(FrappeTestCase): return_doc=1, ) - @change_settings("Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", allow_multi_currency_invoices_against_single_party_account=1 + ) def test_multiple_payment_if_partially_paid_for_multi_currency(self): pi = make_purchase_invoice(currency="USD", conversion_rate=50, qty=1, rate=100, do_not_save=1) pi.credit_to = "Creditors - _TC" diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py index 904d8e83b9c..f53a58bf32d 100644 --- a/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py +++ b/erpnext/accounts/doctype/pos_invoice_merge_log/test_pos_invoice_merge_log.py @@ -2,9 +2,9 @@ # See license.txt import json -import unittest import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.tests.utils import change_settings from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile @@ -19,7 +19,16 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -class TestPOSInvoiceMergeLog(unittest.TestCase): +class UnitTestPosInvoiceMergeLog(UnitTestCase): + """ + Unit tests for PosInvoiceMergeLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPOSInvoiceMergeLog(IntegrationTestCase): def test_consolidated_invoice_creation(self): frappe.db.sql("delete from `tabPOS Invoice`") @@ -288,7 +297,7 @@ class TestPOSInvoiceMergeLog(unittest.TestCase): frappe.db.sql("delete from `tabPOS Profile`") frappe.db.sql("delete from `tabPOS Invoice`") - @change_settings( + @IntegrationTestCase.change_settings( "System Settings", {"number_format": "#,###.###", "currency_precision": 3, "float_precision": 3} ) def test_consolidation_round_off_error_3(self): diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index 0f91532c05f..e184fdfc42f 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -5,7 +5,7 @@ import unittest import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -15,7 +15,16 @@ from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.get_item_details import get_item_details -class TestPricingRule(FrappeTestCase): +class UnitTestPricingRule(UnitTestCase): + """ + Unit tests for PricingRule. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPricingRule(IntegrationTestCase): def setUp(self): delete_existing_pricing_rules() setup_pricing_rule_data() diff --git a/erpnext/accounts/doctype/process_payment_reconciliation/test_process_payment_reconciliation.py b/erpnext/accounts/doctype/process_payment_reconciliation/test_process_payment_reconciliation.py index ad1e952579d..68a87960802 100644 --- a/erpnext/accounts/doctype/process_payment_reconciliation/test_process_payment_reconciliation.py +++ b/erpnext/accounts/doctype/process_payment_reconciliation/test_process_payment_reconciliation.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestProcessPaymentReconciliation(FrappeTestCase): +class UnitTestProcessPaymentReconciliation(UnitTestCase): + """ + Unit tests for ProcessPaymentReconciliation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestProcessPaymentReconciliation(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/process_payment_reconciliation_log/test_process_payment_reconciliation_log.py b/erpnext/accounts/doctype/process_payment_reconciliation_log/test_process_payment_reconciliation_log.py index c2da62e2de4..6705820e8b3 100644 --- a/erpnext/accounts/doctype/process_payment_reconciliation_log/test_process_payment_reconciliation_log.py +++ b/erpnext/accounts/doctype/process_payment_reconciliation_log/test_process_payment_reconciliation_log.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestProcessPaymentReconciliationLog(FrappeTestCase): +class UnitTestProcessPaymentReconciliationLog(UnitTestCase): + """ + Unit tests for ProcessPaymentReconciliationLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestProcessPaymentReconciliationLog(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py index 92dbb5ef273..1419567a33e 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, getdate, today from erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts import ( @@ -14,7 +14,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestProcessStatementOfAccounts(AccountsTestMixin, FrappeTestCase): +class TestProcessStatementOfAccounts(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/doctype/process_subscription/test_process_subscription.py b/erpnext/accounts/doctype/process_subscription/test_process_subscription.py index 723695f1ab2..ad52f72cf0f 100644 --- a/erpnext/accounts/doctype/process_subscription/test_process_subscription.py +++ b/erpnext/accounts/doctype/process_subscription/test_process_subscription.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestProcessSubscription(FrappeTestCase): +class UnitTestProcessSubscription(UnitTestCase): + """ + Unit tests for ProcessSubscription. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestProcessSubscription(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 02596dc9275..e3d0d3c39e7 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, cint, flt, getdate, nowdate, today import erpnext @@ -42,7 +42,7 @@ test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Templ test_ignore = ["Serial No"] -class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): +class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin): @classmethod def setUpClass(self): unlink_payment_on_cancel_of_invoice() @@ -461,7 +461,9 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.total, expected_values[i][2]) - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_purchase_invoice_with_advance(self): from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( test_records as jv_test_records, @@ -516,7 +518,9 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): ) ) - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_invoice_with_advance_and_multi_payment_terms(self): from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( test_records as jv_test_records, @@ -1251,7 +1255,9 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): acc_settings.submit_journal_entriessubmit_journal_entries = 0 acc_settings.save() - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_gain_loss_with_advance_entry(self): unlink_enabled = frappe.db.get_single_value( "Accounts Settings", "unlink_payment_on_cancellation_of_invoice" @@ -1452,7 +1458,9 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): ) frappe.db.set_value("Company", "_Test Company", "exchange_gain_loss_account", original_account) - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_purchase_invoice_advance_taxes(self): from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -2035,7 +2043,7 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): pi.delete() - @change_settings("Buying Settings", {"supplier_group": None}) + @IntegrationTestCase.change_settings("Buying Settings", {"supplier_group": None}) def test_purchase_invoice_without_supplier_group(self): # Create a Supplier test_supplier_name = "_Test Supplier Without Supplier Group" diff --git a/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py b/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py index f631ef437d6..2b59a746b1a 100644 --- a/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py +++ b/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py @@ -4,7 +4,7 @@ import frappe from frappe import qb from frappe.query_builder.functions import Sum -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, nowdate, today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -14,7 +14,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.accounts.utils import get_fiscal_year -class TestRepostAccountingLedger(AccountsTestMixin, FrappeTestCase): +class TestRepostAccountingLedger(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() @@ -114,7 +114,7 @@ class TestRepostAccountingLedger(AccountsTestMixin, FrappeTestCase): ral.append("vouchers", {"voucher_type": si.doctype, "voucher_no": si.name}) self.assertRaises(frappe.ValidationError, ral.save) - @change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1}) + @IntegrationTestCase.change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1}) def test_04_pcv_validation(self): # Clear old GL entries so PCV can be submitted. gl = frappe.qb.DocType("GL Entry") diff --git a/erpnext/accounts/doctype/repost_accounting_ledger_settings/test_repost_accounting_ledger_settings.py b/erpnext/accounts/doctype/repost_accounting_ledger_settings/test_repost_accounting_ledger_settings.py index ec4e87ffc00..dac5835d728 100644 --- a/erpnext/accounts/doctype/repost_accounting_ledger_settings/test_repost_accounting_ledger_settings.py +++ b/erpnext/accounts/doctype/repost_accounting_ledger_settings/test_repost_accounting_ledger_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestRepostAccountingLedgerSettings(FrappeTestCase): +class UnitTestRepostAccountingLedgerSettings(UnitTestCase): + """ + Unit tests for RepostAccountingLedgerSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestRepostAccountingLedgerSettings(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/repost_payment_ledger/test_repost_payment_ledger.py b/erpnext/accounts/doctype/repost_payment_ledger/test_repost_payment_ledger.py index 781726a1e3d..ef169f28eff 100644 --- a/erpnext/accounts/doctype/repost_payment_ledger/test_repost_payment_ledger.py +++ b/erpnext/accounts/doctype/repost_payment_ledger/test_repost_payment_ledger.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestRepostPaymentLedger(FrappeTestCase): +class UnitTestRepostPaymentLedger(UnitTestCase): + """ + Unit tests for RepostPaymentLedger. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestRepostPaymentLedger(IntegrationTestCase): pass diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 0c7d33e3e5f..2c1657f2835 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -7,7 +7,7 @@ import json import frappe from frappe import qb from frappe.model.dynamic_links import get_dynamic_link_map -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, flt, format_date, getdate, nowdate, today import erpnext @@ -46,7 +46,16 @@ from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import from erpnext.stock.utils import get_incoming_rate, get_stock_balance -class TestSalesInvoice(FrappeTestCase): +class UnitTestSalesInvoice(UnitTestCase): + """ + Unit tests for SalesInvoice. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSalesInvoice(IntegrationTestCase): def setUp(self): from erpnext.stock.doctype.stock_ledger_entry.test_stock_ledger_entry import create_items @@ -194,7 +203,9 @@ class TestSalesInvoice(FrappeTestCase): self.assertRaises(frappe.LinkExistsError, si.cancel) unlink_payment_on_cancel_of_invoice() - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_payment_entry_unlink_against_standalone_credit_note(self): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry @@ -1383,7 +1394,9 @@ class TestSalesInvoice(FrappeTestCase): dn.submit() return dn - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_sales_invoice_with_advance(self): from erpnext.accounts.doctype.journal_entry.test_journal_entry import ( test_records as jv_test_records, @@ -2885,7 +2898,7 @@ class TestSalesInvoice(FrappeTestCase): sales_invoice.save() self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC") - @change_settings("Selling Settings", {"enable_discount_accounting": 1}) + @IntegrationTestCase.change_settings("Selling Settings", {"enable_discount_accounting": 1}) def test_sales_invoice_with_discount_accounting_enabled(self): discount_account = create_account( account_name="Discount Account", @@ -2902,7 +2915,7 @@ class TestSalesInvoice(FrappeTestCase): check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1)) - @change_settings("Selling Settings", {"enable_discount_accounting": 1}) + @IntegrationTestCase.change_settings("Selling Settings", {"enable_discount_accounting": 1}) def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self): from erpnext.accounts.doctype.repost_accounting_ledger.test_repost_accounting_ledger import ( update_repost_settings, @@ -3336,7 +3349,7 @@ class TestSalesInvoice(FrappeTestCase): si.commission_rate = commission_rate self.assertRaises(frappe.ValidationError, si.save) - @change_settings("Accounts Settings", {"acc_frozen_upto": add_days(getdate(), 1)}) + @IntegrationTestCase.change_settings("Accounts Settings", {"acc_frozen_upto": add_days(getdate(), 1)}) def test_sales_invoice_submission_post_account_freezing_date(self): si = create_sales_invoice(do_not_save=True) si.posting_date = add_days(getdate(), 1) @@ -3372,7 +3385,7 @@ class TestSalesInvoice(FrappeTestCase): frappe.db.set_single_value("Accounts Settings", "over_billing_allowance", over_billing_allowance) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", { "book_deferred_entries_via_journal_entry": 1, @@ -3492,7 +3505,9 @@ class TestSalesInvoice(FrappeTestCase): account.disabled = 0 account.save() - @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1} + ) def test_gain_loss_with_advance_entry(self): from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry @@ -3655,7 +3670,7 @@ class TestSalesInvoice(FrappeTestCase): set_advance_flag(company="_Test Company", flag=0, default_account="") - @change_settings("Selling Settings", {"customer_group": None, "territory": None}) + @IntegrationTestCase.change_settings("Selling Settings", {"customer_group": None, "territory": None}) def test_sales_invoice_without_customer_group_and_territory(self): # create a customer if not frappe.db.exists("Customer", "_Test Simple Customer"): @@ -3673,7 +3688,7 @@ class TestSalesInvoice(FrappeTestCase): self.assertEqual(si.customer_group, None) self.assertEqual(si.territory, None) - @change_settings("Selling Settings", {"allow_negative_rates_for_items": 0}) + @IntegrationTestCase.change_settings("Selling Settings", {"allow_negative_rates_for_items": 0}) def test_sales_return_negative_rate(self): si = create_sales_invoice(is_return=1, qty=-2, rate=-10, do_not_save=True) self.assertRaises(frappe.ValidationError, si.save) @@ -4089,7 +4104,7 @@ class TestSalesInvoice(FrappeTestCase): self.assertEqual(len(actual), 4) self.assertEqual(expected, actual) - @change_settings("Accounts Settings", {"enable_common_party_accounting": True}) + @IntegrationTestCase.change_settings("Accounts Settings", {"enable_common_party_accounting": True}) def test_common_party_with_foreign_currency_jv(self): from erpnext.accounts.doctype.account.test_account import create_account from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import ( diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index 75626933ace..926abfea5a0 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils.data import ( add_days, add_months, @@ -21,7 +21,16 @@ from erpnext.accounts.doctype.subscription.subscription import get_prorata_facto test_dependencies = ("UOM", "Item Group", "Item") -class TestSubscription(FrappeTestCase): +class UnitTestSubscription(UnitTestCase): + """ + Unit tests for Subscription. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSubscription(IntegrationTestCase): def setUp(self): make_plans() create_parties() diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py index 1e3939d98a4..66639190efd 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py @@ -6,7 +6,7 @@ import unittest import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -16,7 +16,16 @@ from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_i test_dependencies = ["Supplier Group", "Customer Group"] -class TestTaxWithholdingCategory(FrappeTestCase): +class UnitTestTaxWithholdingCategory(UnitTestCase): + """ + Unit tests for TaxWithholdingCategory. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestTaxWithholdingCategory(IntegrationTestCase): @classmethod def setUpClass(self): # create relevant supplier, etc diff --git a/erpnext/accounts/doctype/unreconcile_payment/test_unreconcile_payment.py b/erpnext/accounts/doctype/unreconcile_payment/test_unreconcile_payment.py index 43dfbfaef60..73c589708bb 100644 --- a/erpnext/accounts/doctype/unreconcile_payment/test_unreconcile_payment.py +++ b/erpnext/accounts/doctype/unreconcile_payment/test_unreconcile_payment.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry @@ -11,7 +11,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -class TestUnreconcilePayment(AccountsTestMixin, FrappeTestCase): +class TestUnreconcilePayment(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/report/accounts_payable/test_accounts_payable.py b/erpnext/accounts/report/accounts_payable/test_accounts_payable.py index 8971dc3d37b..d07b0aa43ad 100644 --- a/erpnext/accounts/report/accounts_payable/test_accounts_payable.py +++ b/erpnext/accounts/report/accounts_payable/test_accounts_payable.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice @@ -7,7 +7,7 @@ from erpnext.accounts.report.accounts_payable.accounts_payable import execute from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestAccountsPayable(AccountsTestMixin, FrappeTestCase): +class TestAccountsPayable(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index 39ca78153c3..88c7909154d 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -1,6 +1,6 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, flt, getdate, today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -10,7 +10,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): +class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() @@ -275,7 +275,7 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): ], ) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0}, ) diff --git a/erpnext/accounts/report/accounts_receivable_summary/test_accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/test_accounts_receivable_summary.py index a98cc6af7a3..d357c0d6273 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/test_accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/test_accounts_receivable_summary.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -8,7 +8,7 @@ from erpnext.accounts.report.accounts_receivable_summary.accounts_receivable_sum from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): +class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.maxDiff = None self.create_company() @@ -112,7 +112,7 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase): self.assertEqual(len(rpt_output), 1) self.assertDictEqual(rpt_output[0], expected_data) - @change_settings("Selling Settings", {"cust_master_name": "Naming Series"}) + @IntegrationTestCase.change_settings("Selling Settings", {"cust_master_name": "Naming Series"}) def test_02_various_filters_and_output(self): filters = { "company": self.company, diff --git a/erpnext/accounts/report/balance_sheet/test_balance_sheet.py b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py index 7c67ecb9f1f..c6934682f22 100644 --- a/erpnext/accounts/report/balance_sheet/test_balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py @@ -2,7 +2,7 @@ # MIT License. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.data import today from erpnext.accounts.report.balance_sheet.balance_sheet import execute @@ -13,7 +13,7 @@ COMPANY_SHORT_NAME = "_TC6" test_dependencies = ["Company"] -class TestBalanceSheet(FrappeTestCase): +class TestBalanceSheet(IntegrationTestCase): def test_balance_sheet(self): frappe.db.sql(f"delete from `tabJournal Entry` where company='{COMPANY}'") frappe.db.sql(f"delete from `tabGL Entry` where company='{COMPANY}'") diff --git a/erpnext/accounts/report/bank_reconciliation_statement/test_bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/test_bank_reconciliation_statement.py index b1753ca9119..7002bb6111a 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/test_bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/test_bank_reconciliation_statement.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_statement import ( execute, @@ -10,7 +10,7 @@ from erpnext.accounts.report.bank_reconciliation_statement.bank_reconciliation_s from erpnext.tests.utils import if_lending_app_installed -class TestBankReconciliationStatement(FrappeTestCase): +class TestBankReconciliationStatement(IntegrationTestCase): def setUp(self): for dt in [ "Journal Entry", diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py index 4ca65dc04e5..50e3e4b23c3 100644 --- a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py +++ b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py @@ -1,6 +1,6 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import nowdate from erpnext.accounts.doctype.account.test_account import create_account @@ -13,7 +13,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.accounts.utils import get_fiscal_year -class TestDeferredRevenueAndExpense(FrappeTestCase, AccountsTestMixin): +class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): @classmethod def setUpClass(self): self.maxDiff = None @@ -72,7 +72,7 @@ class TestDeferredRevenueAndExpense(FrappeTestCase, AccountsTestMixin): def tearDown(self): frappe.db.rollback() - @change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) + @IntegrationTestCase.change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) def test_deferred_revenue(self): self.create_item("_Test Internet Subscription", 0, self.warehouse, self.company) item = frappe.get_doc("Item", self.item) @@ -141,7 +141,7 @@ class TestDeferredRevenueAndExpense(FrappeTestCase, AccountsTestMixin): ] self.assertEqual(report.period_total, expected) - @change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) + @IntegrationTestCase.change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) def test_deferred_expense(self): self.create_item("_Test Office Desk", 0, self.warehouse, self.company) item = frappe.get_doc("Item", self.item) @@ -213,7 +213,7 @@ class TestDeferredRevenueAndExpense(FrappeTestCase, AccountsTestMixin): ] self.assertEqual(report.period_total, expected) - @change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) + @IntegrationTestCase.change_settings("Accounts Settings", {"book_deferred_entries_based_on": "Months"}) def test_zero_months(self): self.create_item("_Test Internet Subscription", 0, self.warehouse, self.company) item = frappe.get_doc("Item", self.item) @@ -280,7 +280,7 @@ class TestDeferredRevenueAndExpense(FrappeTestCase, AccountsTestMixin): ] self.assertEqual(report.period_total, expected) - @change_settings( + @IntegrationTestCase.change_settings( "Accounts Settings", {"book_deferred_entries_based_on": "Months", "book_deferred_entries_via_journal_entry": 0}, ) diff --git a/erpnext/accounts/report/general_and_payment_ledger_comparison/test_general_and_payment_ledger_comparison.py b/erpnext/accounts/report/general_and_payment_ledger_comparison/test_general_and_payment_ledger_comparison.py index afa81b83cfc..8c33bc90965 100644 --- a/erpnext/accounts/report/general_and_payment_ledger_comparison/test_general_and_payment_ledger_comparison.py +++ b/erpnext/accounts/report/general_and_payment_ledger_comparison/test_general_and_payment_ledger_comparison.py @@ -1,6 +1,6 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -10,7 +10,7 @@ from erpnext.accounts.report.general_and_payment_ledger_comparison.general_and_p from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestGeneralAndPaymentLedger(FrappeTestCase, AccountsTestMixin): +class TestGeneralAndPaymentLedger(IntegrationTestCase, AccountsTestMixin): def setUp(self): self.create_company() self.cleanup() diff --git a/erpnext/accounts/report/general_ledger/test_general_ledger.py b/erpnext/accounts/report/general_ledger/test_general_ledger.py index af2c569949a..22cb13b439a 100644 --- a/erpnext/accounts/report/general_ledger/test_general_ledger.py +++ b/erpnext/accounts/report/general_ledger/test_general_ledger.py @@ -3,7 +3,7 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import flt, today from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -11,7 +11,7 @@ from erpnext.accounts.report.general_ledger.general_ledger import execute from erpnext.controllers.sales_and_purchase_return import make_return_doc -class TestGeneralLedger(FrappeTestCase): +class TestGeneralLedger(IntegrationTestCase): def setUp(self): self.company = "_Test Company" self.clear_old_entries() diff --git a/erpnext/accounts/report/gross_profit/test_gross_profit.py b/erpnext/accounts/report/gross_profit/test_gross_profit.py index 7bece206883..8bb5bfa81ff 100644 --- a/erpnext/accounts/report/gross_profit/test_gross_profit.py +++ b/erpnext/accounts/report/gross_profit/test_gross_profit.py @@ -1,6 +1,6 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import flt, nowdate from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_delivery_note @@ -12,7 +12,7 @@ from erpnext.stock.doctype.item.test_item import create_item from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -class TestGrossProfit(FrappeTestCase): +class TestGrossProfit(IntegrationTestCase): def setUp(self): self.create_company() self.create_item() diff --git a/erpnext/accounts/report/item_wise_purchase_register/test_item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/test_item_wise_purchase_register.py index 3884854ba7f..5a2fe7e23ce 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/test_item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/test_item_wise_purchase_register.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import getdate, today from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice @@ -7,7 +7,7 @@ from erpnext.accounts.report.item_wise_purchase_register.item_wise_purchase_regi from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestItemWisePurchaseRegister(AccountsTestMixin, FrappeTestCase): +class TestItemWisePurchaseRegister(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_supplier() diff --git a/erpnext/accounts/report/item_wise_sales_register/test_item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/test_item_wise_sales_register.py index 6fd5d601e84..34ec398e7f3 100644 --- a/erpnext/accounts/report/item_wise_sales_register/test_item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/test_item_wise_sales_register.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import getdate, today from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -7,7 +7,7 @@ from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register i from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestItemWiseSalesRegister(AccountsTestMixin, FrappeTestCase): +class TestItemWiseSalesRegister(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/report/payment_ledger/test_payment_ledger.py b/erpnext/accounts/report/payment_ledger/test_payment_ledger.py index c982f3166e7..1225fb70101 100644 --- a/erpnext/accounts/report/payment_ledger/test_payment_ledger.py +++ b/erpnext/accounts/report/payment_ledger/test_payment_ledger.py @@ -1,13 +1,13 @@ import frappe from frappe import qb -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice from erpnext.accounts.report.payment_ledger.payment_ledger import execute -class TestPaymentLedger(FrappeTestCase): +class TestPaymentLedger(IntegrationTestCase): def setUp(self): self.create_company() self.cleanup() diff --git a/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py index 816c2b9950f..82c530cdc78 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py +++ b/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py @@ -2,7 +2,7 @@ # MIT License. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import getdate, today from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -11,7 +11,7 @@ from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement from erpnext.accounts.test.accounts_mixin import AccountsTestMixin -class TestProfitAndLossStatement(AccountsTestMixin, FrappeTestCase): +class TestProfitAndLossStatement(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.create_customer() diff --git a/erpnext/accounts/report/purchase_register/test_purchase_register.py b/erpnext/accounts/report/purchase_register/test_purchase_register.py index a7a5c07152b..6f61c44db02 100644 --- a/erpnext/accounts/report/purchase_register/test_purchase_register.py +++ b/erpnext/accounts/report/purchase_register/test_purchase_register.py @@ -2,13 +2,13 @@ # MIT License. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_months, today from erpnext.accounts.report.purchase_register.purchase_register import execute -class TestPurchaseRegister(FrappeTestCase): +class TestPurchaseRegister(IntegrationTestCase): def test_purchase_register(self): frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company 6'") frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 6'") diff --git a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py index 7515616b0b8..323ad9d61f7 100644 --- a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py @@ -2,7 +2,7 @@ # MIT License. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry @@ -16,7 +16,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.accounts.utils import get_fiscal_year -class TestTaxWithholdingDetails(AccountsTestMixin, FrappeTestCase): +class TestTaxWithholdingDetails(AccountsTestMixin, IntegrationTestCase): def setUp(self): self.create_company() self.clear_old_entries() diff --git a/erpnext/accounts/report/trial_balance/test_trial_balance.py b/erpnext/accounts/report/trial_balance/test_trial_balance.py index 4682ac4500a..db44ffaa86c 100644 --- a/erpnext/accounts/report/trial_balance/test_trial_balance.py +++ b/erpnext/accounts/report/trial_balance/test_trial_balance.py @@ -2,13 +2,13 @@ # MIT License. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.accounts.report.trial_balance.trial_balance import execute -class TestTrialBalance(FrappeTestCase): +class TestTrialBalance(IntegrationTestCase): def setUp(self): from erpnext.accounts.doctype.account.test_account import create_account from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center diff --git a/erpnext/accounts/test_party.py b/erpnext/accounts/test_party.py index 9d3de5e8282..986a5b5d680 100644 --- a/erpnext/accounts/test_party.py +++ b/erpnext/accounts/test_party.py @@ -1,10 +1,10 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.accounts.party import get_default_price_list -class PartyTestCase(FrappeTestCase): +class PartyTestCase(IntegrationTestCase): def test_get_default_price_list_should_return_none_for_invalid_group(self): customer = frappe.get_doc( { diff --git a/erpnext/assets/doctype/asset_activity/test_asset_activity.py b/erpnext/assets/doctype/asset_activity/test_asset_activity.py index 7a21559c520..01d02d43f1c 100644 --- a/erpnext/assets/doctype/asset_activity/test_asset_activity.py +++ b/erpnext/assets/doctype/asset_activity/test_asset_activity.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestAssetActivity(FrappeTestCase): +class UnitTestAssetActivity(UnitTestCase): + """ + Unit tests for AssetActivity. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAssetActivity(IntegrationTestCase): pass diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py index c9fa0ba59da..61e3761719e 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import cstr, flt from erpnext.assets.doctype.asset.depreciation import ( @@ -15,7 +15,16 @@ from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_sched ) -class TestAssetDepreciationSchedule(FrappeTestCase): +class UnitTestAssetDepreciationSchedule(UnitTestCase): + """ + Unit tests for AssetDepreciationSchedule. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAssetDepreciationSchedule(IntegrationTestCase): def setUp(self): create_asset_data() diff --git a/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py b/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py index 8d00a24f6b2..a739a7551db 100644 --- a/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py +++ b/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import cstr from erpnext.assets.doctype.asset.test_asset import create_asset @@ -11,7 +11,16 @@ from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_sched ) -class TestAssetShiftAllocation(FrappeTestCase): +class UnitTestAssetShiftAllocation(UnitTestCase): + """ + Unit tests for AssetShiftAllocation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAssetShiftAllocation(IntegrationTestCase): @classmethod def setUpClass(cls): create_asset_shift_factors() diff --git a/erpnext/assets/doctype/asset_shift_factor/test_asset_shift_factor.py b/erpnext/assets/doctype/asset_shift_factor/test_asset_shift_factor.py index 75073673c0c..9416d325cc2 100644 --- a/erpnext/assets/doctype/asset_shift_factor/test_asset_shift_factor.py +++ b/erpnext/assets/doctype/asset_shift_factor/test_asset_shift_factor.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestAssetShiftFactor(FrappeTestCase): +class UnitTestAssetShiftFactor(UnitTestCase): + """ + Unit tests for AssetShiftFactor. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAssetShiftFactor(IntegrationTestCase): pass diff --git a/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py b/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py index 01bb615a3e1..4cd27de01e7 100644 --- a/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py +++ b/erpnext/bulk_transaction/doctype/bulk_transaction_log/test_bulk_transaction_log.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestBulkTransactionLog(FrappeTestCase): +class UnitTestBulkTransactionLog(UnitTestCase): + """ + Unit tests for BulkTransactionLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBulkTransactionLog(IntegrationTestCase): pass diff --git a/erpnext/bulk_transaction/doctype/bulk_transaction_log_detail/test_bulk_transaction_log_detail.py b/erpnext/bulk_transaction/doctype/bulk_transaction_log_detail/test_bulk_transaction_log_detail.py index 5217b601f87..ecfdbdba49b 100644 --- a/erpnext/bulk_transaction/doctype/bulk_transaction_log_detail/test_bulk_transaction_log_detail.py +++ b/erpnext/bulk_transaction/doctype/bulk_transaction_log_detail/test_bulk_transaction_log_detail.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestBulkTransactionLogDetail(FrappeTestCase): +class UnitTestBulkTransactionLogDetail(UnitTestCase): + """ + Unit tests for BulkTransactionLogDetail. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBulkTransactionLogDetail(IntegrationTestCase): pass diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index c7e79fec4c0..68cab872d8f 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -5,7 +5,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, flt, getdate, nowdate from frappe.utils.data import today @@ -28,7 +28,16 @@ from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( ) -class TestPurchaseOrder(FrappeTestCase): +class UnitTestPurchaseOrder(UnitTestCase): + """ + Unit tests for PurchaseOrder. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPurchaseOrder(IntegrationTestCase): def test_purchase_order_qty(self): po = create_purchase_order(qty=1, do_not_save=True) @@ -735,7 +744,9 @@ class TestPurchaseOrder(FrappeTestCase): pi.insert() self.assertTrue(pi.get("payment_schedule")) - @change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1} + ) def test_advance_payment_entry_unlink_against_purchase_order(self): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry @@ -806,7 +817,9 @@ class TestPurchaseOrder(FrappeTestCase): company_doc.book_advance_payments_in_separate_party_account = False company_doc.save() - @change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1} + ) def test_advance_paid_upon_payment_entry_cancellation(self): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry @@ -1067,7 +1080,7 @@ class TestPurchaseOrder(FrappeTestCase): self.assertEqual(po.items[0].qty, 30) self.assertEqual(po.items[0].fg_item_qty, 30) - @change_settings("Buying Settings", {"auto_create_subcontracting_order": 1}) + @IntegrationTestCase.change_settings("Buying Settings", {"auto_create_subcontracting_order": 1}) def test_auto_create_subcontracting_order(self): from erpnext.controllers.tests.test_subcontracting_controller import ( make_bom_for_subcontracted_items, diff --git a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py index 4effe13d02c..63d995f562b 100644 --- a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py @@ -5,7 +5,7 @@ from urllib.parse import urlparse import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import nowdate from erpnext.buying.doctype.request_for_quotation.request_for_quotation import ( @@ -21,7 +21,16 @@ from erpnext.stock.doctype.item.test_item import make_item from erpnext.templates.pages.rfq import check_supplier_has_docname_access -class TestRequestforQuotation(FrappeTestCase): +class UnitTestRequestForQuotation(UnitTestCase): + """ + Unit tests for RequestForQuotation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestRequestforQuotation(IntegrationTestCase): def test_rfq_qty(self): rfq = make_request_for_quotation(qty=0, do_not_save=True) with self.assertRaises(InvalidQtyError): diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index e4475c7ee38..29caec86cce 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -3,7 +3,7 @@ import frappe -from frappe.test_runner import make_test_records +from frappe.tests.utils import make_test_records from erpnext.accounts.party import get_due_date from erpnext.controllers.website_list_for_contact import get_customers_suppliers @@ -12,10 +12,19 @@ from erpnext.exceptions import PartyDisabled test_dependencies = ["Payment Term", "Payment Terms Template"] test_records = frappe.get_test_records("Supplier") -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSupplier(FrappeTestCase): +class UnitTestSupplier(UnitTestCase): + """ + Unit tests for Supplier. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSupplier(IntegrationTestCase): def test_get_supplier_group_details(self): doc = frappe.new_doc("Supplier Group") doc.supplier_group_name = "_Testing Supplier Group" @@ -180,7 +189,7 @@ def create_supplier(**args): return doc -class TestSupplierPortal(FrappeTestCase): +class TestSupplierPortal(IntegrationTestCase): def test_portal_user_can_access_supplier_data(self): supplier = create_supplier() diff --git a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py index 33465700f41..9008fa73443 100644 --- a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -3,12 +3,21 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.controllers.accounts_controller import InvalidQtyError -class TestPurchaseOrder(FrappeTestCase): +class UnitTestSupplierQuotation(UnitTestCase): + """ + Unit tests for SupplierQuotation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPurchaseOrder(IntegrationTestCase): def test_supplier_quotation_qty(self): sq = frappe.copy_doc(test_records[0]) sq.items[0].qty = 0 diff --git a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py index 2694f96fbe3..de7e8bd7b12 100644 --- a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py @@ -3,10 +3,19 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSupplierScorecard(FrappeTestCase): +class UnitTestSupplierScorecard(UnitTestCase): + """ + Unit tests for SupplierScorecard. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSupplierScorecard(IntegrationTestCase): def test_create_scorecard(self): doc = make_supplier_scorecard().insert() self.assertEqual(doc.name, valid_scorecard[0].get("supplier")) diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py index 90468d6c168..516d0e38222 100644 --- a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py +++ b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py @@ -3,10 +3,19 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSupplierScorecardCriteria(FrappeTestCase): +class UnitTestSupplierScorecardCriteria(UnitTestCase): + """ + Unit tests for SupplierScorecardCriteria. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSupplierScorecardCriteria(IntegrationTestCase): def test_variables_exist(self): delete_test_scorecards() for d in test_good_criteria: diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py index 60d84644cf5..cbf06e074c1 100644 --- a/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py +++ b/erpnext/buying/doctype/supplier_scorecard_variable/test_supplier_scorecard_variable.py @@ -3,14 +3,23 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.buying.doctype.supplier_scorecard_variable.supplier_scorecard_variable import ( VariablePathNotFound, ) -class TestSupplierScorecardVariable(FrappeTestCase): +class UnitTestSupplierScorecardVariable(UnitTestCase): + """ + Unit tests for SupplierScorecardVariable. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSupplierScorecardVariable(IntegrationTestCase): def test_variable_exist(self): for d in test_existing_variables: my_doc = frappe.get_doc("Supplier Scorecard Variable", d.get("name")) diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index ebceb7f655a..f344730a7fa 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -2,8 +2,8 @@ # For license information, please see license.txt -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestProcurementTracker(FrappeTestCase): +class TestProcurementTracker(IntegrationTestCase): pass diff --git a/erpnext/buying/report/requested_items_to_order_and_receive/test_requested_items_to_order_and_receive.py b/erpnext/buying/report/requested_items_to_order_and_receive/test_requested_items_to_order_and_receive.py index 5b84113a9cf..b8cc10986db 100644 --- a/erpnext/buying/report/requested_items_to_order_and_receive/test_requested_items_to_order_and_receive.py +++ b/erpnext/buying/report/requested_items_to_order_and_receive/test_requested_items_to_order_and_receive.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, today from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt @@ -13,7 +13,7 @@ from erpnext.stock.doctype.item.test_item import create_item from erpnext.stock.doctype.material_request.material_request import make_purchase_order -class TestRequestedItemsToOrderAndReceive(FrappeTestCase): +class TestRequestedItemsToOrderAndReceive(IntegrationTestCase): def setUp(self) -> None: create_item("Test MR Report Item") self.setup_material_request() # to order and receive diff --git a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py index d90be66af94..5a4c8ec6ba0 100644 --- a/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py +++ b/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py @@ -7,7 +7,7 @@ import copy import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.buying.report.subcontracted_item_to_be_received.subcontracted_item_to_be_received import ( execute, @@ -24,7 +24,7 @@ from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order im ) -class TestSubcontractedItemToBeReceived(FrappeTestCase): +class TestSubcontractedItemToBeReceived(IntegrationTestCase): def test_pending_and_received_qty(self): make_service_item("Subcontracted Service Item 1") service_items = [ diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py index 7b4ec5c2f39..3553906ae63 100644 --- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py +++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py @@ -4,7 +4,7 @@ # Decompiled by https://python-decompiler.com import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.buying.report.subcontracted_raw_materials_to_be_transferred.subcontracted_raw_materials_to_be_transferred import ( execute, @@ -17,7 +17,7 @@ from erpnext.controllers.tests.test_subcontracting_controller import ( from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry -class TestSubcontractedItemToBeTransferred(FrappeTestCase): +class TestSubcontractedItemToBeTransferred(IntegrationTestCase): def test_pending_and_transferred_qty(self): make_service_item("Subcontracted Service Item 1") service_items = [ diff --git a/erpnext/controllers/tests/test_accounts_controller.py b/erpnext/controllers/tests/test_accounts_controller.py index b2f8fce3d31..07ecbdbeb9d 100644 --- a/erpnext/controllers/tests/test_accounts_controller.py +++ b/erpnext/controllers/tests/test_accounts_controller.py @@ -5,7 +5,7 @@ import frappe from frappe import qb from frappe.query_builder.functions import Sum -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, getdate, nowdate from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -46,7 +46,7 @@ def make_supplier(supplier_name, currency=None): return supplier_name -class TestAccountsController(FrappeTestCase): +class TestAccountsController(IntegrationTestCase): """ Test Exchange Gain/Loss booking on various scenarios. Test Cases are numbered for better organization @@ -805,7 +805,9 @@ class TestAccountsController(FrappeTestCase): self.assertEqual(exc_je_for_si, []) self.assertEqual(exc_je_for_pe, []) - @change_settings("Stock Settings", {"allow_internal_transfer_at_arms_length_price": 1}) + @IntegrationTestCase.change_settings( + "Stock Settings", {"allow_internal_transfer_at_arms_length_price": 1} + ) def test_16_internal_transfer_at_arms_length_price(self): from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse diff --git a/erpnext/controllers/tests/test_distributed_discount.py b/erpnext/controllers/tests/test_distributed_discount.py index e4dbdbb1480..ae2381152ec 100644 --- a/erpnext/controllers/tests/test_distributed_discount.py +++ b/erpnext/controllers/tests/test_distributed_discount.py @@ -1,11 +1,11 @@ -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.accounts.test.accounts_mixin import AccountsTestMixin from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order -class TestTaxesAndTotals(AccountsTestMixin, FrappeTestCase): +class TestTaxesAndTotals(AccountsTestMixin, IntegrationTestCase): def test_distributed_discount_amount(self): so = make_sales_order(do_not_save=1) so.apply_discount_on = "Net Total" diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py index 9dbcf6cafd2..340df56fa0e 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -4,7 +4,7 @@ import unittest import frappe import frappe.utils from frappe.model import mapper -from frappe.test_runner import make_test_records +from frappe.tests.utils import make_test_records from frappe.utils import add_months, nowdate diff --git a/erpnext/controllers/tests/test_subcontracting_controller.py b/erpnext/controllers/tests/test_subcontracting_controller.py index dfd4351dcad..84f7e057dea 100644 --- a/erpnext/controllers/tests/test_subcontracting_controller.py +++ b/erpnext/controllers/tests/test_subcontracting_controller.py @@ -5,7 +5,7 @@ import copy from collections import defaultdict import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import cint from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order @@ -25,7 +25,7 @@ from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order im ) -class TestSubcontractingController(FrappeTestCase): +class TestSubcontractingController(IntegrationTestCase): def setUp(self): make_subcontracted_items() make_raw_materials() diff --git a/erpnext/crm/report/sales_pipeline_analytics/test_sales_pipeline_analytics.py b/erpnext/crm/report/sales_pipeline_analytics/test_sales_pipeline_analytics.py index 39d16a09cab..94c3581245a 100644 --- a/erpnext/crm/report/sales_pipeline_analytics/test_sales_pipeline_analytics.py +++ b/erpnext/crm/report/sales_pipeline_analytics/test_sales_pipeline_analytics.py @@ -1,12 +1,12 @@ import unittest import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.crm.report.sales_pipeline_analytics.sales_pipeline_analytics import execute -class TestSalesPipelineAnalytics(FrappeTestCase): +class TestSalesPipelineAnalytics(IntegrationTestCase): def setUp(self): frappe.db.delete("Opportunity") create_company() diff --git a/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py index a6eb18f47bc..148e38fd50d 100644 --- a/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py +++ b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py @@ -1,7 +1,7 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_months, today from erpnext import get_company_currency @@ -10,7 +10,16 @@ from erpnext.stock.doctype.item.test_item import make_item from .blanket_order import make_order -class TestBlanketOrder(FrappeTestCase): +class UnitTestBlanketOrder(UnitTestCase): + """ + Unit tests for BlanketOrder. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBlanketOrder(IntegrationTestCase): def setUp(self): frappe.flags.args = frappe._dict() diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 67a308883b1..2c6806c2f1e 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -6,7 +6,8 @@ from collections import deque from functools import partial import frappe -from frappe.tests.utils import FrappeTestCase, timeout +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import timeout from frappe.utils import cstr, flt from erpnext.controllers.tests.test_subcontracting_controller import ( @@ -25,7 +26,16 @@ test_records = frappe.get_test_records("BOM") test_dependencies = ["Item", "Quality Inspection Template"] -class TestBOM(FrappeTestCase): +class UnitTestBom(UnitTestCase): + """ + Unit tests for Bom. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBOM(IntegrationTestCase): @timeout def test_get_items(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict diff --git a/erpnext/manufacturing/doctype/bom_creator/test_bom_creator.py b/erpnext/manufacturing/doctype/bom_creator/test_bom_creator.py index a835de78274..79b9e669ae3 100644 --- a/erpnext/manufacturing/doctype/bom_creator/test_bom_creator.py +++ b/erpnext/manufacturing/doctype/bom_creator/test_bom_creator.py @@ -4,7 +4,7 @@ import random import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.manufacturing.doctype.bom_creator.bom_creator import ( add_item, @@ -13,7 +13,16 @@ from erpnext.manufacturing.doctype.bom_creator.bom_creator import ( from erpnext.stock.doctype.item.test_item import make_item -class TestBOMCreator(FrappeTestCase): +class UnitTestBomCreator(UnitTestCase): + """ + Unit tests for BomCreator. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBOMCreator(IntegrationTestCase): def setUp(self) -> None: create_items() diff --git a/erpnext/manufacturing/doctype/bom_update_log/test_bom_update_log.py b/erpnext/manufacturing/doctype/bom_update_log/test_bom_update_log.py index 13bf69f672f..43d49a3e27d 100644 --- a/erpnext/manufacturing/doctype/bom_update_log/test_bom_update_log.py +++ b/erpnext/manufacturing/doctype/bom_update_log/test_bom_update_log.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.manufacturing.doctype.bom_update_log.bom_update_log import ( BOMMissingError, @@ -16,7 +16,16 @@ from erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool import ( test_records = frappe.get_test_records("BOM") -class TestBOMUpdateLog(FrappeTestCase): +class UnitTestBomUpdateLog(UnitTestCase): + """ + Unit tests for BomUpdateLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBOMUpdateLog(IntegrationTestCase): "Test BOM Update Tool Operations via BOM Update Log." def setUp(self): diff --git a/erpnext/manufacturing/doctype/bom_update_tool/test_bom_update_tool.py b/erpnext/manufacturing/doctype/bom_update_tool/test_bom_update_tool.py index 2026f629147..ff4aa2553a4 100644 --- a/erpnext/manufacturing/doctype/bom_update_tool/test_bom_update_tool.py +++ b/erpnext/manufacturing/doctype/bom_update_tool/test_bom_update_tool.py @@ -2,7 +2,8 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase, timeout +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import timeout from erpnext.manufacturing.doctype.bom_update_log.test_bom_update_log import ( update_cost_in_all_boms_in_test, @@ -14,7 +15,16 @@ from erpnext.stock.doctype.item.test_item import create_item test_records = frappe.get_test_records("BOM") -class TestBOMUpdateTool(FrappeTestCase): +class UnitTestBomUpdateTool(UnitTestCase): + """ + Unit tests for BomUpdateTool. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBOMUpdateTool(IntegrationTestCase): "Test major functions run via BOM Update Tool." def tearDown(self): diff --git a/erpnext/manufacturing/doctype/job_card/test_job_card.py b/erpnext/manufacturing/doctype/job_card/test_job_card.py index b0644b4e8d2..ad78eff7ae1 100644 --- a/erpnext/manufacturing/doctype/job_card/test_job_card.py +++ b/erpnext/manufacturing/doctype/job_card/test_job_card.py @@ -5,8 +5,8 @@ from typing import Literal import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records from frappe.utils import random_string from frappe.utils.data import add_to_date, now, today @@ -26,7 +26,16 @@ from erpnext.manufacturing.doctype.workstation.test_workstation import make_work from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -class TestJobCard(FrappeTestCase): +class UnitTestJobCard(UnitTestCase): + """ + Unit tests for JobCard. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestJobCard(IntegrationTestCase): def setUp(self): make_bom_for_jc_tests() self.transfer_material_against: Literal["Work Order", "Job Card"] = "Work Order" @@ -206,7 +215,7 @@ class TestJobCard(FrappeTestCase): # transfer was made for 2 fg qty in first transfer Stock Entry self.assertEqual(transfer_entry_2.fg_completed_qty, 0) - @change_settings("Manufacturing Settings", {"job_card_excess_transfer": 1}) + @IntegrationTestCase.change_settings("Manufacturing Settings", {"job_card_excess_transfer": 1}) def test_job_card_excess_material_transfer(self): "Test transferring more than required RM against Job Card." self.transfer_material_against = "Job Card" @@ -249,7 +258,7 @@ class TestJobCard(FrappeTestCase): # JC is Completed with excess transfer self.assertEqual(job_card.status, "Completed") - @change_settings("Manufacturing Settings", {"job_card_excess_transfer": 0}) + @IntegrationTestCase.change_settings("Manufacturing Settings", {"job_card_excess_transfer": 0}) def test_job_card_excess_material_transfer_block(self): self.transfer_material_against = "Job Card" self.source_warehouse = "Stores - _TC" @@ -272,7 +281,7 @@ class TestJobCard(FrappeTestCase): transfer_entry_2.insert() self.assertRaises(JobCardOverTransferError, transfer_entry_2.submit) - @change_settings("Manufacturing Settings", {"job_card_excess_transfer": 0}) + @IntegrationTestCase.change_settings("Manufacturing Settings", {"job_card_excess_transfer": 0}) def test_job_card_excess_material_transfer_with_no_reference(self): self.transfer_material_against = "Job Card" self.source_warehouse = "Stores - _TC" @@ -380,7 +389,7 @@ class TestJobCard(FrappeTestCase): self.assertEqual(transfer_entry.items[0].item_code, "_Test Item") self.assertEqual(transfer_entry.items[0].qty, 2) - @change_settings( + @IntegrationTestCase.change_settings( "Manufacturing Settings", {"add_corrective_operation_cost_in_finished_good_valuation": 1} ) def test_corrective_costing(self): diff --git a/erpnext/manufacturing/doctype/plant_floor/test_plant_floor.py b/erpnext/manufacturing/doctype/plant_floor/test_plant_floor.py index 2fac2113366..cbc231754f9 100644 --- a/erpnext/manufacturing/doctype/plant_floor/test_plant_floor.py +++ b/erpnext/manufacturing/doctype/plant_floor/test_plant_floor.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestPlantFloor(FrappeTestCase): +class UnitTestPlantFloor(UnitTestCase): + """ + Unit tests for PlantFloor. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPlantFloor(IntegrationTestCase): pass diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index 55cf9426743..56e593e91a1 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -1,7 +1,7 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_to_date, flt, getdate, now_datetime, nowdate from erpnext.controllers.item_variant import create_variant @@ -22,7 +22,16 @@ from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import ) -class TestProductionPlan(FrappeTestCase): +class UnitTestProductionPlan(UnitTestCase): + """ + Unit tests for ProductionPlan. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestProductionPlan(IntegrationTestCase): def setUp(self): for item in [ "Test Production Item 1", diff --git a/erpnext/manufacturing/doctype/routing/test_routing.py b/erpnext/manufacturing/doctype/routing/test_routing.py index e069aea274a..6fe6a5456e5 100644 --- a/erpnext/manufacturing/doctype/routing/test_routing.py +++ b/erpnext/manufacturing/doctype/routing/test_routing.py @@ -1,15 +1,24 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records from erpnext.manufacturing.doctype.job_card.job_card import OperationSequenceError from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record from erpnext.stock.doctype.item.test_item import make_item -class TestRouting(FrappeTestCase): +class UnitTestRouting(UnitTestCase): + """ + Unit tests for Routing. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestRouting(IntegrationTestCase): @classmethod def setUpClass(cls): cls.item_code = "Test Routing Item - A" diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py index c722aa94fcf..68acb9fd9f2 100644 --- a/erpnext/manufacturing/doctype/work_order/test_work_order.py +++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py @@ -3,7 +3,8 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings, timeout +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import timeout from frappe.utils import add_days, add_months, add_to_date, cint, flt, now, today from erpnext.manufacturing.doctype.job_card.job_card import JobCardCancelError @@ -34,7 +35,16 @@ from erpnext.stock.utils import get_bin test_dependencies = ["BOM"] -class TestWorkOrder(FrappeTestCase): +class UnitTestWorkOrder(UnitTestCase): + """ + Unit tests for WorkOrder. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWorkOrder(IntegrationTestCase): def setUp(self): self.warehouse = "_Test Warehouse 2 - _TC" self.item = "_Test Item" @@ -1142,7 +1152,9 @@ class TestWorkOrder(FrappeTestCase): frappe.db.set_single_value("Manufacturing Settings", "backflush_raw_materials_based_on", "BOM") - @change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1}) + @IntegrationTestCase.change_settings( + "Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1} + ) def test_auto_batch_creation(self): from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom @@ -1163,7 +1175,9 @@ class TestWorkOrder(FrappeTestCase): except frappe.MandatoryError: self.fail("Batch generation causing failing in Work Order") - @change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1}) + @IntegrationTestCase.change_settings( + "Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1} + ) def test_auto_serial_no_creation(self): from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom @@ -1196,7 +1210,9 @@ class TestWorkOrder(FrappeTestCase): except frappe.MandatoryError: self.fail("Batch generation causing failing in Work Order") - @change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1}) + @IntegrationTestCase.change_settings( + "Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1} + ) def test_auto_serial_no_batch_creation(self): from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom @@ -1248,7 +1264,7 @@ class TestWorkOrder(FrappeTestCase): return serial_nos - @change_settings( + @IntegrationTestCase.change_settings( "Manufacturing Settings", {"backflush_raw_materials_based_on": "Material Transferred for Manufacture"}, ) @@ -1278,7 +1294,7 @@ class TestWorkOrder(FrappeTestCase): for index, row in enumerate(ste_manu.get("items"), start=1): self.assertEqual(index, row.idx) - @change_settings( + @IntegrationTestCase.change_settings( "Manufacturing Settings", {"backflush_raw_materials_based_on": "Material Transferred for Manufacture"}, ) @@ -2061,7 +2077,7 @@ class TestWorkOrder(FrappeTestCase): frappe.db.set_single_value("Manufacturing Settings", "set_op_cost_and_scrape_from_sub_assemblies", 0) - @change_settings( + @IntegrationTestCase.change_settings( "Manufacturing Settings", {"material_consumption": 1, "get_rm_cost_from_consumption_entry": 1} ) def test_get_rm_cost_from_consumption_entry(self): diff --git a/erpnext/manufacturing/doctype/workstation/test_workstation.py b/erpnext/manufacturing/doctype/workstation/test_workstation.py index 1eb47ae577b..84712f8fa1b 100644 --- a/erpnext/manufacturing/doctype/workstation/test_workstation.py +++ b/erpnext/manufacturing/doctype/workstation/test_workstation.py @@ -1,8 +1,8 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors # See license.txt import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records from erpnext.manufacturing.doctype.operation.test_operation import make_operation from erpnext.manufacturing.doctype.routing.test_routing import create_routing, setup_bom @@ -17,7 +17,16 @@ test_records = frappe.get_test_records("Workstation") make_test_records("Workstation") -class TestWorkstation(FrappeTestCase): +class UnitTestWorkstation(UnitTestCase): + """ + Unit tests for Workstation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWorkstation(IntegrationTestCase): def test_validate_timings(self): check_if_within_operating_hours( "_Test Workstation 1", "Operation 1", "2013-02-02 11:00:00", "2013-02-02 19:00:00" diff --git a/erpnext/manufacturing/doctype/workstation_type/test_workstation_type.py b/erpnext/manufacturing/doctype/workstation_type/test_workstation_type.py index aa7a3ee92f6..e36d3f2a583 100644 --- a/erpnext/manufacturing/doctype/workstation_type/test_workstation_type.py +++ b/erpnext/manufacturing/doctype/workstation_type/test_workstation_type.py @@ -2,10 +2,19 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestWorkstationType(FrappeTestCase): +class UnitTestWorkstationType(UnitTestCase): + """ + Unit tests for WorkstationType. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWorkstationType(IntegrationTestCase): pass diff --git a/erpnext/manufacturing/report/bom_stock_calculated/test_bom_stock_calculated.py b/erpnext/manufacturing/report/bom_stock_calculated/test_bom_stock_calculated.py index 8ad980fa19a..8f5f768a698 100644 --- a/erpnext/manufacturing/report/bom_stock_calculated/test_bom_stock_calculated.py +++ b/erpnext/manufacturing/report/bom_stock_calculated/test_bom_stock_calculated.py @@ -1,7 +1,7 @@ # Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom from erpnext.manufacturing.report.bom_stock_calculated.bom_stock_calculated import ( @@ -10,7 +10,7 @@ from erpnext.manufacturing.report.bom_stock_calculated.bom_stock_calculated impo from erpnext.stock.doctype.item.test_item import make_item -class TestBOMStockCalculated(FrappeTestCase): +class TestBOMStockCalculated(IntegrationTestCase): def setUp(self): self.fg_item, self.rm_items = create_items() self.boms = create_boms(self.fg_item, self.rm_items) diff --git a/erpnext/manufacturing/report/bom_stock_report/test_bom_stock_report.py b/erpnext/manufacturing/report/bom_stock_report/test_bom_stock_report.py index 1c56ebe24d4..4571129cdce 100644 --- a/erpnext/manufacturing/report/bom_stock_report/test_bom_stock_report.py +++ b/erpnext/manufacturing/report/bom_stock_report/test_bom_stock_report.py @@ -4,7 +4,7 @@ import frappe from frappe.exceptions import ValidationError -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import floor from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom @@ -15,7 +15,7 @@ from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry -class TestBomStockReport(FrappeTestCase): +class TestBomStockReport(IntegrationTestCase): def setUp(self): self.warehouse = "_Test Warehouse - _TC" self.fg_item, self.rm_items = create_items() diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index e5996c2da9d..f3f61d55b58 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, getdate, nowdate from erpnext.projects.doctype.project_template.test_project_template import make_project_template @@ -14,7 +14,16 @@ test_records = frappe.get_test_records("Project") test_ignore = ["Sales Order"] -class TestProject(FrappeTestCase): +class UnitTestProject(UnitTestCase): + """ + Unit tests for Project. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestProject(IntegrationTestCase): def test_project_with_template_having_no_parent_and_depend_tasks(self): project_name = "Test Project with Template - No Parent and Dependend Tasks" frappe.db.sql(""" delete from tabTask where project = %s """, project_name) diff --git a/erpnext/quality_management/doctype/quality_procedure/test_quality_procedure.py b/erpnext/quality_management/doctype/quality_procedure/test_quality_procedure.py index 467186debd9..97bca751965 100644 --- a/erpnext/quality_management/doctype/quality_procedure/test_quality_procedure.py +++ b/erpnext/quality_management/doctype/quality_procedure/test_quality_procedure.py @@ -2,12 +2,21 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from .quality_procedure import add_node -class TestQualityProcedure(FrappeTestCase): +class UnitTestQualityProcedure(UnitTestCase): + """ + Unit tests for QualityProcedure. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestQualityProcedure(IntegrationTestCase): def test_add_node(self): procedure = create_procedure( { diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index c7751937aaa..1ddda0399b0 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -5,8 +5,8 @@ import json import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records from frappe.utils import flt from erpnext.accounts.party import get_due_date @@ -23,7 +23,16 @@ test_dependencies = ["Payment Term", "Payment Terms Template"] test_records = frappe.get_test_records("Customer") -class TestCustomer(FrappeTestCase): +class UnitTestCustomer(UnitTestCase): + """ + Unit tests for Customer. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestCustomer(IntegrationTestCase): def setUp(self): if not frappe.get_value("Item", "_Test Item"): make_test_records("Item") diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py index f98cbd7e9a3..42f981f94b7 100644 --- a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.controllers.queries import item_query @@ -18,7 +18,16 @@ def create_party_specific_item(**args): psi.insert() -class TestPartySpecificItem(FrappeTestCase): +class UnitTestPartySpecificItem(UnitTestCase): + """ + Unit tests for PartySpecificItem. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPartySpecificItem(IntegrationTestCase): def setUp(self): self.customer = frappe.get_last_doc("Customer") self.supplier = frappe.get_last_doc("Supplier") diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index e6b92cd7c16..ecbb70a01a0 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, add_months, flt, getdate, nowdate from erpnext.controllers.accounts_controller import InvalidQtyError @@ -10,7 +10,16 @@ from erpnext.controllers.accounts_controller import InvalidQtyError test_dependencies = ["Product Bundle"] -class TestQuotation(FrappeTestCase): +class UnitTestQuotation(UnitTestCase): + """ + Unit tests for Quotation. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestQuotation(IntegrationTestCase): def test_quotation_qty(self): qo = make_quotation(qty=0, do_not_save=True) with self.assertRaises(InvalidQtyError): diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 23ad56e572d..3d4e089e465 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -7,7 +7,7 @@ from unittest.mock import patch import frappe import frappe.permissions from frappe.core.doctype.user_permission.test_user_permission import create_user -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, flt, getdate, nowdate, today from erpnext.accounts.test.accounts_mixin import AccountsTestMixin @@ -33,7 +33,7 @@ from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -class TestSalesOrder(AccountsTestMixin, FrappeTestCase): +class TestSalesOrder(AccountsTestMixin, IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -1316,7 +1316,9 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): self.assertRaises(frappe.LinkExistsError, so_doc.cancel) - @change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1}) + @IntegrationTestCase.change_settings( + "Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1} + ) def test_advance_paid_upon_payment_cancellation(self): from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry @@ -1906,7 +1908,7 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): self.assertEqual(len(dn.packed_items), 1) self.assertEqual(dn.items[0].item_code, "_Test Product Bundle Item Partial 2") - @change_settings("Selling Settings", {"editable_bundle_item_rates": 1}) + @IntegrationTestCase.change_settings("Selling Settings", {"editable_bundle_item_rates": 1}) def test_expired_rate_for_packed_item(self): bundle = "_Test Product Bundle 1" packed_item = "_Packed Item 1" @@ -2198,7 +2200,7 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): self.assertRaises(frappe.ValidationError, so1.update_status, "Draft") - @change_settings("Stock Settings", {"enable_stock_reservation": True}) + @IntegrationTestCase.change_settings("Stock Settings", {"enable_stock_reservation": True}) def test_warehouse_mapping_based_on_stock_reservation(self): self.create_company(company_name="Glass Ceiling", abbr="GC") self.create_item("Lamy Safari 2", True, self.warehouse_stores, self.company, 2000) diff --git a/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py b/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py index 58516f6f625..10e119a2957 100644 --- a/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py +++ b/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py @@ -1,7 +1,7 @@ import datetime import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, add_months, nowdate from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice @@ -14,7 +14,7 @@ from erpnext.stock.doctype.item.test_item import create_item test_dependencies = ["Sales Order", "Item", "Sales Invoice", "Payment Terms Template", "Customer"] -class TestPaymentTermsStatusForSalesOrder(FrappeTestCase): +class TestPaymentTermsStatusForSalesOrder(IntegrationTestCase): def setUp(self): self.cleanup_old_entries() diff --git a/erpnext/selling/report/pending_so_items_for_purchase_request/test_pending_so_items_for_purchase_request.py b/erpnext/selling/report/pending_so_items_for_purchase_request/test_pending_so_items_for_purchase_request.py index e4ad5c622b8..cfb960fd8ad 100644 --- a/erpnext/selling/report/pending_so_items_for_purchase_request/test_pending_so_items_for_purchase_request.py +++ b/erpnext/selling/report/pending_so_items_for_purchase_request/test_pending_so_items_for_purchase_request.py @@ -2,7 +2,7 @@ # For license information, please see license.txt -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_months, nowdate from erpnext.selling.doctype.sales_order.sales_order import make_material_request @@ -12,7 +12,7 @@ from erpnext.selling.report.pending_so_items_for_purchase_request.pending_so_ite ) -class TestPendingSOItemsForPurchaseRequest(FrappeTestCase): +class TestPendingSOItemsForPurchaseRequest(IntegrationTestCase): def test_result_for_partial_material_request(self): so = make_sales_order() mr = make_material_request(so.name) diff --git a/erpnext/selling/report/sales_analytics/test_analytics.py b/erpnext/selling/report/sales_analytics/test_analytics.py index 15f06d9c9b8..af7d93be9bb 100644 --- a/erpnext/selling/report/sales_analytics/test_analytics.py +++ b/erpnext/selling/report/sales_analytics/test_analytics.py @@ -3,13 +3,13 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.selling.report.sales_analytics.sales_analytics import execute -class TestAnalytics(FrappeTestCase): +class TestAnalytics(IntegrationTestCase): def test_sales_analytics(self): frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'") diff --git a/erpnext/selling/report/sales_order_analysis/test_sales_order_analysis.py b/erpnext/selling/report/sales_order_analysis/test_sales_order_analysis.py index 241f4358fba..c147414c38e 100644 --- a/erpnext/selling/report/sales_order_analysis/test_sales_order_analysis.py +++ b/erpnext/selling/report/sales_order_analysis/test_sales_order_analysis.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note, make_sales_invoice @@ -10,7 +10,7 @@ from erpnext.stock.doctype.item.test_item import create_item test_dependencies = ["Sales Order", "Item", "Sales Invoice", "Delivery Note"] -class TestSalesOrderAnalysis(FrappeTestCase): +class TestSalesOrderAnalysis(IntegrationTestCase): def create_sales_order(self, transaction_date, do_not_save=False, do_not_submit=False): item = create_item(item_code="_Test Excavator", is_stock_item=0) so = make_sales_order( diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py index 17186687d97..4e32d7973e8 100644 --- a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py +++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import flt, nowdate from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -13,7 +13,7 @@ from erpnext.selling.report.sales_person_target_variance_based_on_item_group.tes ) -class TestSalesPartnerTargetVarianceBasedOnItemGroup(FrappeTestCase): +class TestSalesPartnerTargetVarianceBasedOnItemGroup(IntegrationTestCase): def setUp(self): self.fiscal_year = get_fiscal_year(nowdate())[0] diff --git a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/test_sales_person_target_variance_based_on_item_group.py b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/test_sales_person_target_variance_based_on_item_group.py index 73ae6d0c852..52bd213a85d 100644 --- a/erpnext/selling/report/sales_person_target_variance_based_on_item_group/test_sales_person_target_variance_based_on_item_group.py +++ b/erpnext/selling/report/sales_person_target_variance_based_on_item_group/test_sales_person_target_variance_based_on_item_group.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import flt, nowdate from erpnext.accounts.utils import get_fiscal_year @@ -9,7 +9,7 @@ from erpnext.selling.report.sales_person_target_variance_based_on_item_group.sal ) -class TestSalesPersonTargetVarianceBasedOnItemGroup(FrappeTestCase): +class TestSalesPersonTargetVarianceBasedOnItemGroup(IntegrationTestCase): def setUp(self): self.fiscal_year = get_fiscal_year(nowdate())[0] diff --git a/erpnext/setup/doctype/incoterm/test_incoterm.py b/erpnext/setup/doctype/incoterm/test_incoterm.py index 06b8c3bda9d..36ae5fd4e6a 100644 --- a/erpnext/setup/doctype/incoterm/test_incoterm.py +++ b/erpnext/setup/doctype/incoterm/test_incoterm.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestIncoterm(FrappeTestCase): +class UnitTestIncoterm(UnitTestCase): + """ + Unit tests for Incoterm. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestIncoterm(IntegrationTestCase): pass diff --git a/erpnext/setup/doctype/transaction_deletion_record/test_transaction_deletion_record.py b/erpnext/setup/doctype/transaction_deletion_record/test_transaction_deletion_record.py index 68d856e7108..77bedaed9ea 100644 --- a/erpnext/setup/doctype/transaction_deletion_record/test_transaction_deletion_record.py +++ b/erpnext/setup/doctype/transaction_deletion_record/test_transaction_deletion_record.py @@ -3,10 +3,19 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestTransactionDeletionRecord(FrappeTestCase): +class UnitTestTransactionDeletionRecord(UnitTestCase): + """ + Unit tests for TransactionDeletionRecord. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestTransactionDeletionRecord(IntegrationTestCase): def setUp(self): create_company("Dunder Mifflin Paper Co") diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py index 3ef0e57c25a..4c761943f12 100644 --- a/erpnext/stock/doctype/batch/test_batch.py +++ b/erpnext/stock/doctype/batch/test_batch.py @@ -5,7 +5,7 @@ import json import frappe from frappe.exceptions import ValidationError -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import cint, flt from frappe.utils.data import add_to_date, getdate @@ -24,7 +24,16 @@ from erpnext.stock.get_item_details import get_item_details from erpnext.stock.serial_batch_bundle import SerialBatchCreation -class TestBatch(FrappeTestCase): +class UnitTestBatch(UnitTestCase): + """ + Unit tests for Batch. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBatch(IntegrationTestCase): def test_item_has_batch_enabled(self): self.assertRaises( ValidationError, diff --git a/erpnext/stock/doctype/bin/test_bin.py b/erpnext/stock/doctype/bin/test_bin.py index e4f5565cd75..66f14d84d51 100644 --- a/erpnext/stock/doctype/bin/test_bin.py +++ b/erpnext/stock/doctype/bin/test_bin.py @@ -2,13 +2,22 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.utils import _create_bin -class TestBin(FrappeTestCase): +class UnitTestBin(UnitTestCase): + """ + Unit tests for Bin. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestBin(IntegrationTestCase): def test_concurrent_inserts(self): """Ensure no duplicates are possible in case of concurrent inserts""" item_code = "_TestConcurrentBin" diff --git a/erpnext/stock/doctype/closing_stock_balance/test_closing_stock_balance.py b/erpnext/stock/doctype/closing_stock_balance/test_closing_stock_balance.py index 7d61f5c9c63..e477de2ff2a 100644 --- a/erpnext/stock/doctype/closing_stock_balance/test_closing_stock_balance.py +++ b/erpnext/stock/doctype/closing_stock_balance/test_closing_stock_balance.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestClosingStockBalance(FrappeTestCase): +class UnitTestClosingStockBalance(UnitTestCase): + """ + Unit tests for ClosingStockBalance. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestClosingStockBalance(IntegrationTestCase): pass diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 73b77f67536..86aea2329ca 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -5,7 +5,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, cstr, flt, getdate, nowdate, nowtime, today from erpnext.accounts.doctype.account.test_account import get_inventory_account @@ -43,7 +43,16 @@ from erpnext.stock.doctype.warehouse.test_warehouse import get_warehouse from erpnext.stock.stock_ledger import get_previous_sle -class TestDeliveryNote(FrappeTestCase): +class UnitTestDeliveryNote(UnitTestCase): + """ + Unit tests for DeliveryNote. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDeliveryNote(IntegrationTestCase): def test_delivery_note_qty(self): dn = create_delivery_note(qty=0, do_not_save=True) with self.assertRaises(InvalidQtyError): diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py index 09f5b2c2c89..40fe4f75df9 100644 --- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py +++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, flt, now_datetime, nowdate import erpnext @@ -14,7 +14,16 @@ from erpnext.stock.doctype.delivery_trip.delivery_trip import ( from erpnext.tests.utils import create_test_contact_and_address -class TestDeliveryTrip(FrappeTestCase): +class UnitTestDeliveryTrip(UnitTestCase): + """ + Unit tests for DeliveryTrip. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDeliveryTrip(IntegrationTestCase): def setUp(self): super().setUp() driver = create_driver() diff --git a/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py b/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py index 8ce954d55e6..b83543b6fbd 100644 --- a/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py +++ b/erpnext/stock/doctype/inventory_dimension/test_inventory_dimension.py @@ -3,7 +3,7 @@ import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_field -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import nowdate, nowtime from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note @@ -19,7 +19,16 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse -class TestInventoryDimension(FrappeTestCase): +class UnitTestInventoryDimension(UnitTestCase): + """ + Unit tests for InventoryDimension. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestInventoryDimension(IntegrationTestCase): def setUp(self): prepare_test_data() create_store_dimension() diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 0b8a0d3e890..934dde3ef41 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -7,7 +7,7 @@ import json import frappe from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.test_runner import make_test_objects -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, today from erpnext.controllers.item_variant import ( @@ -74,7 +74,16 @@ def make_item(item_code=None, properties=None, uoms=None, barcode=None): return item -class TestItem(FrappeTestCase): +class UnitTestItem(UnitTestCase): + """ + Unit tests for Item. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestItem(IntegrationTestCase): def setUp(self): super().setUp() frappe.flags.attribute_values = None @@ -728,13 +737,13 @@ class TestItem(FrappeTestCase): except frappe.ValidationError as e: self.fail(f"stock item considered non-stock item: {e}") - @change_settings("Stock Settings", {"item_naming_by": "Naming Series"}) + @IntegrationTestCase.change_settings("Stock Settings", {"item_naming_by": "Naming Series"}) def test_autoname_series(self): item = frappe.new_doc("Item") item.item_group = "All Item Groups" item.save() # if item code saved without item_code then series worked - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_item_wise_negative_stock(self): """When global settings are disabled check that item that allows negative stock can still consume material in all known stock @@ -746,7 +755,7 @@ class TestItem(FrappeTestCase): self.consume_item_code_with_differet_stock_transactions(item_code=item.name) - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_backdated_negative_stock(self): """same as test above but backdated entries""" from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry @@ -759,7 +768,9 @@ class TestItem(FrappeTestCase): ) self.consume_item_code_with_differet_stock_transactions(item_code=item.name) - @change_settings("Stock Settings", {"sample_retention_warehouse": "_Test Warehouse - _TC"}) + @IntegrationTestCase.change_settings( + "Stock Settings", {"sample_retention_warehouse": "_Test Warehouse - _TC"} + ) def test_retain_sample(self): item = make_item("_TestRetainSample", {"has_batch_no": 1, "retain_sample": 1, "sample_quantity": 1}) diff --git a/erpnext/stock/doctype/item_alternative/test_item_alternative.py b/erpnext/stock/doctype/item_alternative/test_item_alternative.py index 11e45ee06ca..442ae755a7d 100644 --- a/erpnext/stock/doctype/item_alternative/test_item_alternative.py +++ b/erpnext/stock/doctype/item_alternative/test_item_alternative.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import flt from erpnext.controllers.subcontracting_controller import make_rm_stock_entry @@ -26,7 +26,16 @@ from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order im ) -class TestItemAlternative(FrappeTestCase): +class UnitTestItemAlternative(UnitTestCase): + """ + Unit tests for ItemAlternative. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestItemAlternative(IntegrationTestCase): def setUp(self): super().setUp() make_items() diff --git a/erpnext/stock/doctype/item_attribute/test_item_attribute.py b/erpnext/stock/doctype/item_attribute/test_item_attribute.py index a30f0e999f7..f4b49cc538c 100644 --- a/erpnext/stock/doctype/item_attribute/test_item_attribute.py +++ b/erpnext/stock/doctype/item_attribute/test_item_attribute.py @@ -6,12 +6,21 @@ import frappe test_records = frappe.get_test_records("Item Attribute") -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.stock.doctype.item_attribute.item_attribute import ItemAttributeIncrementError -class TestItemAttribute(FrappeTestCase): +class UnitTestItemAttribute(UnitTestCase): + """ + Unit tests for ItemAttribute. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestItemAttribute(IntegrationTestCase): def setUp(self): super().setUp() if frappe.db.exists("Item Attribute", "_Test_Length"): diff --git a/erpnext/stock/doctype/item_price/test_item_price.py b/erpnext/stock/doctype/item_price/test_item_price.py index 63d717c3124..4713f4cf582 100644 --- a/erpnext/stock/doctype/item_price/test_item_price.py +++ b/erpnext/stock/doctype/item_price/test_item_price.py @@ -3,14 +3,23 @@ import frappe -from frappe.test_runner import make_test_records_for_doctype -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records_for_doctype from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem from erpnext.stock.get_item_details import get_price_list_rate_for, process_args -class TestItemPrice(FrappeTestCase): +class UnitTestItemPrice(UnitTestCase): + """ + Unit tests for ItemPrice. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestItemPrice(IntegrationTestCase): def setUp(self): super().setUp() frappe.db.sql("delete from `tabItem Price`") diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py index 39f9ecb915d..b38ea5d5930 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py +++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, add_to_date, flt, now, nowtime, today from erpnext.accounts.doctype.account.test_account import create_account, get_inventory_account @@ -21,7 +21,16 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle from erpnext.stock.serial_batch_bundle import SerialNoValuation -class TestLandedCostVoucher(FrappeTestCase): +class UnitTestLandedCostVoucher(UnitTestCase): + """ + Unit tests for LandedCostVoucher. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestLandedCostVoucher(IntegrationTestCase): def test_landed_cost_voucher(self): frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1) diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py index b383078731d..9d1fd84f932 100644 --- a/erpnext/stock/doctype/material_request/test_material_request.py +++ b/erpnext/stock/doctype/material_request/test_material_request.py @@ -6,7 +6,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import flt, today from erpnext.controllers.accounts_controller import InvalidQtyError @@ -20,7 +20,16 @@ from erpnext.stock.doctype.material_request.material_request import ( ) -class TestMaterialRequest(FrappeTestCase): +class UnitTestMaterialRequest(UnitTestCase): + """ + Unit tests for MaterialRequest. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestMaterialRequest(IntegrationTestCase): def test_material_request_qty(self): mr = frappe.copy_doc(test_records[0]) mr.items[0].qty = 0 diff --git a/erpnext/stock/doctype/packed_item/test_packed_item.py b/erpnext/stock/doctype/packed_item/test_packed_item.py index 24a302f009f..6c710453a98 100644 --- a/erpnext/stock/doctype/packed_item/test_packed_item.py +++ b/erpnext/stock/doctype/packed_item/test_packed_item.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_to_date, nowdate from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note @@ -40,7 +40,16 @@ def create_product_bundle( return bundle, components -class TestPackedItem(FrappeTestCase): +class UnitTestPackedItem(UnitTestCase): + """ + Unit tests for PackedItem. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPackedItem(IntegrationTestCase): "Test impact on Packed Items table in various scenarios." @classmethod @@ -116,7 +125,7 @@ class TestPackedItem(FrappeTestCase): self.assertEqual(so.packed_items[1].qty, 4) self.assertEqual(so.packed_items[3].qty, 12) - @change_settings("Selling Settings", {"editable_bundle_item_rates": 1}) + @IntegrationTestCase.change_settings("Selling Settings", {"editable_bundle_item_rates": 1}) def test_bundle_item_cumulative_price(self): "Test if Bundle Item rate is cumulative from packed items." so = make_sales_order(item_code=self.bundle, qty=2, do_not_submit=True) diff --git a/erpnext/stock/doctype/packing_slip/test_packing_slip.py b/erpnext/stock/doctype/packing_slip/test_packing_slip.py index 08c70bf8e95..dbd9892c4c3 100644 --- a/erpnext/stock/doctype/packing_slip/test_packing_slip.py +++ b/erpnext/stock/doctype/packing_slip/test_packing_slip.py @@ -3,7 +3,7 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle from erpnext.stock.doctype.delivery_note.delivery_note import make_packing_slip @@ -11,7 +11,16 @@ from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delive from erpnext.stock.doctype.item.test_item import make_item -class TestPackingSlip(FrappeTestCase): +class UnitTestPackingSlip(UnitTestCase): + """ + Unit tests for PackingSlip. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPackingSlip(IntegrationTestCase): def test_packing_slip(self): # Step - 1: Create a Product Bundle items = create_items() diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index ef74ec9d627..d719dbb42de 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -3,7 +3,7 @@ import frappe from frappe import _dict -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.selling.doctype.sales_order.sales_order import create_pick_list from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order @@ -24,7 +24,16 @@ from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import ( test_dependencies = ["Item", "Sales Invoice", "Stock Entry", "Batch"] -class TestPickList(FrappeTestCase): +class UnitTestPickList(UnitTestCase): + """ + Unit tests for PickList. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPickList(IntegrationTestCase): def test_pick_list_picks_warehouse_for_each_item(self): item_code = make_item().name try: diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 6c731b7493d..488d0f5f5b3 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, cint, cstr, flt, get_datetime, getdate, nowtime, today from pypika import functions as fn @@ -26,7 +26,16 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse -class TestPurchaseReceipt(FrappeTestCase): +class UnitTestPurchaseReceipt(UnitTestCase): + """ + Unit tests for PurchaseReceipt. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPurchaseReceipt(IntegrationTestCase): def setUp(self): frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1) @@ -1234,7 +1243,7 @@ class TestPurchaseReceipt(FrappeTestCase): automatically_fetch_payment_terms(enable=0) - @change_settings("Stock Settings", {"allow_negative_stock": 1}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 1}) def test_neg_to_positive(self): from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry diff --git a/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py b/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py index 9178229c018..bfdf3715fc9 100644 --- a/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py +++ b/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.stock.doctype.batch.test_batch import make_new_batch from erpnext.stock.doctype.item.test_item import make_item @@ -16,7 +16,16 @@ from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse from erpnext.stock.get_item_details import get_conversion_factor -class TestPutawayRule(FrappeTestCase): +class UnitTestPutawayRule(UnitTestCase): + """ + Unit tests for PutawayRule. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPutawayRule(IntegrationTestCase): def setUp(self): if not frappe.db.exists("Item", "_Rice"): make_item( diff --git a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py index 9656a6252e7..3343b208263 100644 --- a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py +++ b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import nowdate from erpnext.controllers.stock_controller import ( @@ -18,7 +18,16 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry # test_records = frappe.get_test_records('Quality Inspection') -class TestQualityInspection(FrappeTestCase): +class UnitTestQualityInspection(UnitTestCase): + """ + Unit tests for QualityInspection. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestQualityInspection(IntegrationTestCase): def setUp(self): super().setUp() create_item("_Test Item with QA") @@ -218,7 +227,7 @@ class TestQualityInspection(FrappeTestCase): qa.save() self.assertEqual(qa.status, "Accepted") - @change_settings("System Settings", {"number_format": "#.###,##"}) + @IntegrationTestCase.change_settings("System Settings", {"number_format": "#.###,##"}) def test_diff_number_format(self): self.assertEqual(frappe.db.get_default("number_format"), "#.###,##") # sanity check diff --git a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py index 7aa2fc3e7d8..2f9bc8246cd 100644 --- a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, call import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, add_to_date, now, nowdate, today from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -21,7 +21,7 @@ from erpnext.stock.tests.test_utils import StockTestMixin from erpnext.stock.utils import PendingRepostingError -class TestRepostItemValuation(FrappeTestCase, StockTestMixin): +class TestRepostItemValuation(IntegrationTestCase, StockTestMixin): def tearDown(self): frappe.flags.dont_execute_stock_reposts = False @@ -195,7 +195,7 @@ class TestRepostItemValuation(FrappeTestCase, StockTestMixin): riv.set_status("Skipped") - @change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) + @IntegrationTestCase.change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) def test_prevention_of_cancelled_transaction_riv(self): frappe.flags.dont_execute_stock_reposts = True @@ -373,7 +373,7 @@ class TestRepostItemValuation(FrappeTestCase, StockTestMixin): accounts_settings.acc_frozen_upto = "" accounts_settings.save() - @change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) + @IntegrationTestCase.change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) def test_create_repost_entry_for_cancelled_document(self): pr = make_purchase_receipt( company="_Test Company with perpetual inventory", diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py index 5fe79384e6d..f156f993fd6 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py @@ -4,7 +4,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import flt, nowtime, today from erpnext.stock.doctype.item.test_item import make_item @@ -16,7 +16,16 @@ from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle impor from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry -class TestSerialandBatchBundle(FrappeTestCase): +class UnitTestSerialAndBatchBundle(UnitTestCase): + """ + Unit tests for SerialAndBatchBundle. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSerialandBatchBundle(IntegrationTestCase): def test_inward_outward_serial_valuation(self): from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt @@ -524,7 +533,9 @@ class TestSerialandBatchBundle(FrappeTestCase): make_serial_nos(item_code, serial_nos) self.assertTrue(frappe.db.exists("Serial No", serial_no_id)) - @change_settings("Stock Settings", {"auto_create_serial_and_batch_bundle_for_outward": 1}) + @IntegrationTestCase.change_settings( + "Stock Settings", {"auto_create_serial_and_batch_bundle_for_outward": 1} + ) def test_duplicate_serial_and_batch_bundle(self): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index 79291af3a10..9e2861cc186 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -7,7 +7,7 @@ import frappe from frappe import _dict -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note from erpnext.stock.doctype.item.test_item import make_item @@ -25,7 +25,16 @@ test_dependencies = ["Item"] test_records = frappe.get_test_records("Serial No") -class TestSerialNo(FrappeTestCase): +class UnitTestSerialNo(UnitTestCase): + """ + Unit tests for SerialNo. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSerialNo(IntegrationTestCase): def tearDown(self): frappe.db.rollback() diff --git a/erpnext/stock/doctype/shipment/test_shipment.py b/erpnext/stock/doctype/shipment/test_shipment.py index 4d4eadc339b..197f6f8342d 100644 --- a/erpnext/stock/doctype/shipment/test_shipment.py +++ b/erpnext/stock/doctype/shipment/test_shipment.py @@ -4,12 +4,21 @@ from datetime import date, timedelta import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from erpnext.stock.doctype.delivery_note.delivery_note import make_shipment -class TestShipment(FrappeTestCase): +class UnitTestShipment(UnitTestCase): + """ + Unit tests for Shipment. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestShipment(IntegrationTestCase): def test_shipment_from_delivery_note(self): delivery_note = create_test_delivery_note() delivery_note.submit() diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 29bc7561768..e4aa2fd8427 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -3,7 +3,7 @@ from frappe.permissions import add_user_permission, remove_user_permission -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, cstr, flt, get_time, getdate, nowtime, today from erpnext.accounts.doctype.account.test_account import get_inventory_account @@ -49,7 +49,16 @@ def get_sle(**args): ) -class TestStockEntry(FrappeTestCase): +class UnitTestStockEntry(UnitTestCase): + """ + Unit tests for StockEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestStockEntry(IntegrationTestCase): def tearDown(self): frappe.db.rollback() frappe.set_user("Administrator") @@ -857,7 +866,7 @@ class TestStockEntry(FrappeTestCase): fg_cost = next(filter(lambda x: x.item_code == "_Test FG Item 2", stock_entry.get("items"))).amount self.assertEqual(fg_cost, flt(rm_cost + bom_operation_cost + work_order.additional_operating_cost, 2)) - @change_settings("Manufacturing Settings", {"material_consumption": 1}) + @IntegrationTestCase.change_settings("Manufacturing Settings", {"material_consumption": 1}) def test_work_order_manufacture_with_material_consumption(self): from erpnext.manufacturing.doctype.work_order.work_order import ( make_stock_entry as _make_stock_entry, @@ -1261,7 +1270,7 @@ class TestStockEntry(FrappeTestCase): self.assertEqual(se.value_difference, 0.0) self.assertEqual(se.total_incoming_value, se.total_outgoing_value) - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_future_negative_sle(self): # Initialize item, batch, warehouse, opening qty item_code = "_Test Future Neg Item" @@ -1304,7 +1313,7 @@ class TestStockEntry(FrappeTestCase): self.assertRaises(NegativeStockError, create_stock_entries, sequence_of_entries) - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_future_negative_sle_batch(self): from erpnext.stock.doctype.batch.test_batch import TestBatch @@ -1432,7 +1441,7 @@ class TestStockEntry(FrappeTestCase): self.assertEqual(se.items[0].item_name, item.item_name) self.assertEqual(se.items[0].stock_uom, item.stock_uom) - @change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) + @IntegrationTestCase.change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) def test_reposting_for_depedent_warehouse(self): from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import repost_sl_entries from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py index 42e402e0005..4c9f019986d 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py @@ -8,7 +8,7 @@ from uuid import uuid4 import frappe from frappe.core.page.permission_manager.permission_manager import reset from frappe.custom.doctype.property_setter.property_setter import make_property_setter -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, add_to_date, flt, today from erpnext.accounts.doctype.gl_entry.gl_entry import rename_gle_sle_docs @@ -30,7 +30,7 @@ from erpnext.stock.stock_ledger import get_previous_sle from erpnext.stock.tests.test_utils import StockTestMixin -class TestStockLedgerEntry(FrappeTestCase, StockTestMixin): +class TestStockLedgerEntry(IntegrationTestCase, StockTestMixin): def setUp(self): items = create_items() reset("Stock Entry") @@ -1218,7 +1218,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin): self.assertEqual(sle[0].qty_after_transaction, 105) self.assertEqual(sle[0].actual_qty, 100) - @change_settings("System Settings", {"float_precision": 3, "currency_precision": 2}) + @IntegrationTestCase.change_settings("System Settings", {"float_precision": 3, "currency_precision": 2}) def test_transfer_invariants(self): """Extact stock value should be transferred.""" @@ -1253,7 +1253,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin): ) self.assertEqual(abs(sles[0].stock_value_difference), sles[1].stock_value_difference) - @change_settings("System Settings", {"float_precision": 4}) + @IntegrationTestCase.change_settings("System Settings", {"float_precision": 4}) def test_negative_qty_with_precision(self): "Test if system precision is respected while validating negative qty." from erpnext.stock.doctype.item.test_item import create_item @@ -1293,7 +1293,7 @@ class TestStockLedgerEntry(FrappeTestCase, StockTestMixin): self.assertEqual(flt(get_stock_balance(item_code, warehouse), 3), 0.000) - @change_settings("System Settings", {"float_precision": 4}) + @IntegrationTestCase.change_settings("System Settings", {"float_precision": 4}) def test_future_negative_qty_with_precision(self): """ Ledger: @@ -1551,7 +1551,16 @@ def get_unique_suffix(): return str(uuid4())[:8].upper() -class TestDeferredNaming(FrappeTestCase): +class UnitTestStockLedgerEntry(UnitTestCase): + """ + Unit tests for StockLedgerEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDeferredNaming(IntegrationTestCase): @classmethod def setUpClass(cls) -> None: super().setUpClass() diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 9bb6ba9ec90..9a7a352264b 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -7,7 +7,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, cstr, flt, nowdate, nowtime from erpnext.accounts.utils import get_stock_and_account_balance @@ -28,7 +28,7 @@ from erpnext.stock.tests.test_utils import StockTestMixin from erpnext.stock.utils import get_incoming_rate, get_stock_value_on, get_valuation_method -class TestStockReconciliation(FrappeTestCase, StockTestMixin): +class TestStockReconciliation(IntegrationTestCase, StockTestMixin): @classmethod def setUpClass(cls): create_batch_or_serial_no_items() @@ -417,7 +417,7 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): assertBalance(pr2, 11) assertBalance(sr4, 6) # check if future stock reco is unaffected - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_backdated_stock_reco_future_negative_stock(self): """ Test if a backdated stock reco causes future negative stock and is blocked. @@ -466,7 +466,7 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): dn2.cancel() pr1.cancel() - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_backdated_stock_reco_cancellation_future_negative_stock(self): """ Test if a backdated stock reco cancellation that causes future negative stock is blocked. @@ -672,7 +672,7 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): self.assertEqual(flt(sl_entry.actual_qty), 1.0) self.assertEqual(flt(sl_entry.qty_after_transaction), 1.0) - @change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) + @IntegrationTestCase.change_settings("Stock Reposting Settings", {"item_based_reposting": 0}) def test_backdated_stock_reco_entry(self): from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry diff --git a/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py b/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py index ddbf0b2dc25..6e37d246e7f 100644 --- a/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py +++ b/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py @@ -4,7 +4,7 @@ from random import randint import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import today from erpnext.selling.doctype.sales_order.sales_order import create_pick_list, make_delivery_note @@ -21,13 +21,22 @@ from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry impor from erpnext.stock.utils import get_stock_balance -class TestStockReservationEntry(FrappeTestCase): +class UnitTestStockReservationEntry(UnitTestCase): + """ + Unit tests for StockReservationEntry. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestStockReservationEntry(IntegrationTestCase): def setUp(self) -> None: self.warehouse = "_Test Warehouse - _TC" self.sr_item = make_item(properties={"is_stock_item": 1, "valuation_rate": 100}) create_material_receipt(items={self.sr_item.name: self.sr_item}, warehouse=self.warehouse, qty=100) - @change_settings("Stock Settings", {"allow_negative_stock": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"allow_negative_stock": 0}) def test_validate_stock_reservation_settings(self) -> None: from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import ( validate_stock_reservation_settings, @@ -40,10 +49,10 @@ class TestStockReservationEntry(FrappeTestCase): ) # Case - 1: When `Stock Reservation` is disabled in `Stock Settings`, throw `ValidationError` - with change_settings("Stock Settings", {"enable_stock_reservation": 0}): + with self.change_settings("Stock Settings", {"enable_stock_reservation": 0}): self.assertRaises(frappe.ValidationError, validate_stock_reservation_settings, voucher) - with change_settings("Stock Settings", {"enable_stock_reservation": 1}): + with self.change_settings("Stock Settings", {"enable_stock_reservation": 1}): # Case - 2: When `Voucher Type` is not allowed for `Stock Reservation`, throw `ValidationError` voucher.doctype = "NOT ALLOWED" self.assertRaises(frappe.ValidationError, validate_stock_reservation_settings, voucher) @@ -120,7 +129,9 @@ class TestStockReservationEntry(FrappeTestCase): sre.load_from_db() self.assertEqual(sre.status, "Cancelled") - @change_settings("Stock Settings", {"allow_negative_stock": 0, "enable_stock_reservation": 1}) + @IntegrationTestCase.change_settings( + "Stock Settings", {"allow_negative_stock": 0, "enable_stock_reservation": 1} + ) def test_update_reserved_qty_in_voucher(self) -> None: # Step - 1: Create a `Sales Order` so = make_sales_order( @@ -187,7 +198,9 @@ class TestStockReservationEntry(FrappeTestCase): self.assertEqual(sre1.status, "Cancelled") self.assertEqual(so.items[0].stock_reserved_qty, 0) - @change_settings("Stock Settings", {"allow_negative_stock": 0, "enable_stock_reservation": 1}) + @IntegrationTestCase.change_settings( + "Stock Settings", {"allow_negative_stock": 0, "enable_stock_reservation": 1} + ) def test_cant_consume_reserved_stock(self) -> None: from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import ( cancel_stock_reservation_entries, @@ -235,7 +248,7 @@ class TestStockReservationEntry(FrappeTestCase): se.submit() se.cancel() - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, @@ -267,12 +280,12 @@ class TestStockReservationEntry(FrappeTestCase): ) # Test - 1: Stock should not be reserved if the Available Qty to Reserve is less than the Ordered Qty and Partial Reservation is disabled in Stock Settings. - with change_settings("Stock Settings", {"allow_partial_reservation": 0}): + with self.change_settings("Stock Settings", {"allow_partial_reservation": 0}): so.create_stock_reservation_entries() self.assertFalse(has_reserved_stock("Sales Order", so.name)) # Test - 2: Stock should be Partially Reserved if the Partial Reservation is enabled in Stock Settings. - with change_settings("Stock Settings", {"allow_partial_reservation": 1}): + with self.change_settings("Stock Settings", {"allow_partial_reservation": 1}): so.create_stock_reservation_entries() so.load_from_db() self.assertTrue(has_reserved_stock("Sales Order", so.name)) @@ -342,7 +355,7 @@ class TestStockReservationEntry(FrappeTestCase): self.assertEqual(sre_details.status, "Partially Delivered") # Test - 8: Over Delivery against Sales Order, SRE Delivered Qty should not be greater than the SRE Reserved Qty. - with change_settings("Stock Settings", {"over_delivery_receipt_allowance": 100}): + with self.change_settings("Stock Settings", {"over_delivery_receipt_allowance": 100}): dn2 = make_delivery_note(so.name) for item in dn2.items: @@ -363,7 +376,7 @@ class TestStockReservationEntry(FrappeTestCase): for sre_detail in sre_details: self.assertEqual(sre_detail.reserved_qty, sre_detail.delivered_qty) - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, @@ -483,7 +496,7 @@ class TestStockReservationEntry(FrappeTestCase): # Test - 9: After Delivery Note cancellation, SB Entry Delivered Qty should be `0`. self.assertEqual(sb_entry.delivered_qty, 0) - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, @@ -564,7 +577,7 @@ class TestStockReservationEntry(FrappeTestCase): # Test - 3: Reserved Serial/Batch Nos should be equal to Picked Serial/Batch Nos. self.assertSetEqual(picked_sb_details, reserved_sb_details) - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, @@ -644,7 +657,7 @@ class TestStockReservationEntry(FrappeTestCase): # Test - 3: Reserved Serial/Batch Nos should be equal to PR Item Serial/Batch Nos. self.assertEqual(set(sb_details), set(reserved_sb_details)) - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, diff --git a/erpnext/stock/doctype/stock_settings/test_stock_settings.py b/erpnext/stock/doctype/stock_settings/test_stock_settings.py index 4b5ae43385a..cce4ce74f41 100644 --- a/erpnext/stock/doctype/stock_settings/test_stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/test_stock_settings.py @@ -3,10 +3,19 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestStockSettings(FrappeTestCase): +class UnitTestStockSettings(UnitTestCase): + """ + Unit tests for StockSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestStockSettings(IntegrationTestCase): def setUp(self): super().setUp() frappe.db.set_single_value("Stock Settings", "clean_description_html", 0) diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py index 02d64cadfe6..9c2cca995cf 100644 --- a/erpnext/stock/doctype/warehouse/test_warehouse.py +++ b/erpnext/stock/doctype/warehouse/test_warehouse.py @@ -2,8 +2,8 @@ # License: GNU General Public License v3. See license.txt import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase +from frappe.tests.utils import make_test_records import erpnext from erpnext.accounts.doctype.account.test_account import create_account @@ -14,7 +14,16 @@ from erpnext.stock.doctype.warehouse.warehouse import convert_to_group_or_ledger test_records = frappe.get_test_records("Warehouse") -class TestWarehouse(FrappeTestCase): +class UnitTestWarehouse(UnitTestCase): + """ + Unit tests for Warehouse. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWarehouse(IntegrationTestCase): def setUp(self): super().setUp() if not frappe.get_value("Item", "_Test Item"): diff --git a/erpnext/stock/report/item_shortage_report/test_item_shortage_report.py b/erpnext/stock/report/item_shortage_report/test_item_shortage_report.py index 5884c32acc7..76549a14927 100644 --- a/erpnext/stock/report/item_shortage_report/test_item_shortage_report.py +++ b/erpnext/stock/report/item_shortage_report/test_item_shortage_report.py @@ -2,7 +2,7 @@ # For license information, please see license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.stock.doctype.item.test_item import make_item @@ -11,7 +11,7 @@ from erpnext.stock.report.item_shortage_report.item_shortage_report import ( ) -class TestItemShortageReport(FrappeTestCase): +class TestItemShortageReport(IntegrationTestCase): def test_item_shortage_report(self): item = make_item().name so = make_sales_order(item_code=item) diff --git a/erpnext/stock/report/reserved_stock/test_reserved_stock.py b/erpnext/stock/report/reserved_stock/test_reserved_stock.py index 16906fbed00..cf74df5c160 100644 --- a/erpnext/stock/report/reserved_stock/test_reserved_stock.py +++ b/erpnext/stock/report/reserved_stock/test_reserved_stock.py @@ -2,7 +2,7 @@ # See license.txt from random import randint -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.utils.data import today from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order @@ -14,7 +14,7 @@ from erpnext.stock.doctype.stock_reservation_entry.test_stock_reservation_entry from erpnext.stock.report.reserved_stock.reserved_stock import get_data as reserved_stock_report -class TestReservedStock(FrappeTestCase): +class TestReservedStock(IntegrationTestCase): def setUp(self) -> None: super().setUp() self.stock_qty = 100 @@ -24,7 +24,7 @@ class TestReservedStock(FrappeTestCase): cancel_all_stock_reservation_entries() return super().tearDown() - @change_settings( + @IntegrationTestCase.change_settings( "Stock Settings", { "allow_negative_stock": 0, diff --git a/erpnext/stock/report/stock_ageing/test_stock_ageing.py b/erpnext/stock/report/stock_ageing/test_stock_ageing.py index c0c007e5015..24ede79d9e8 100644 --- a/erpnext/stock/report/stock_ageing/test_stock_ageing.py +++ b/erpnext/stock/report/stock_ageing/test_stock_ageing.py @@ -2,12 +2,12 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.stock.report.stock_ageing.stock_ageing import FIFOSlots, format_report_data -class TestStockAgeing(FrappeTestCase): +class TestStockAgeing(IntegrationTestCase): def setUp(self) -> None: self.filters = frappe._dict(company="_Test Company", to_date="2021-12-10", ranges=["30", "60", "90"]) diff --git a/erpnext/stock/report/stock_analytics/test_stock_analytics.py b/erpnext/stock/report/stock_analytics/test_stock_analytics.py index b4f086c3631..70be5cf4e81 100644 --- a/erpnext/stock/report/stock_analytics/test_stock_analytics.py +++ b/erpnext/stock/report/stock_analytics/test_stock_analytics.py @@ -2,7 +2,7 @@ import datetime import frappe from frappe import _dict -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.data import add_to_date, getdate from erpnext.accounts.utils import get_fiscal_year @@ -16,7 +16,7 @@ def stock_analytics(filters): return col, data -class TestStockAnalyticsReport(FrappeTestCase): +class TestStockAnalyticsReport(IntegrationTestCase): def setUp(self) -> None: self.item = make_item().name self.warehouse = "_Test Warehouse - _TC" diff --git a/erpnext/stock/report/stock_balance/test_stock_balance.py b/erpnext/stock/report/stock_balance/test_stock_balance.py index 8b3dbee7c8d..1b856f3ed0d 100644 --- a/erpnext/stock/report/stock_balance/test_stock_balance.py +++ b/erpnext/stock/report/stock_balance/test_stock_balance.py @@ -2,7 +2,7 @@ from typing import Any import frappe from frappe import _dict -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from erpnext.stock.doctype.item.test_item import make_item @@ -15,7 +15,7 @@ def stock_balance(filters): return [_dict(row) for row in execute(filters)[1]] -class TestStockBalance(FrappeTestCase): +class TestStockBalance(IntegrationTestCase): # ----------- utils def setUp(self): diff --git a/erpnext/stock/report/stock_ledger/test_stock_ledger_report.py b/erpnext/stock/report/stock_ledger/test_stock_ledger_report.py index 12800f2216a..db583b1239b 100644 --- a/erpnext/stock/report/stock_ledger/test_stock_ledger_report.py +++ b/erpnext/stock/report/stock_ledger/test_stock_ledger_report.py @@ -2,7 +2,7 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, today from erpnext.maintenance.doctype.maintenance_schedule.test_maintenance_schedule import ( @@ -10,7 +10,7 @@ from erpnext.maintenance.doctype.maintenance_schedule.test_maintenance_schedule ) -class TestStockLedgerReeport(FrappeTestCase): +class TestStockLedgerReeport(IntegrationTestCase): def setUp(self) -> None: make_serial_item_with_serial("_Test Stock Report Serial Item") self.filters = frappe._dict( diff --git a/erpnext/stock/tests/test_get_item_details.py b/erpnext/stock/tests/test_get_item_details.py index 30f748a65e0..8d857448027 100644 --- a/erpnext/stock/tests/test_get_item_details.py +++ b/erpnext/stock/tests/test_get_item_details.py @@ -1,6 +1,6 @@ import frappe -from frappe.test_runner import make_test_records -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase +from frappe.tests.utils import make_test_records from erpnext.stock.get_item_details import get_item_details @@ -8,7 +8,7 @@ test_ignore = ["BOM"] test_dependencies = ["Customer", "Supplier", "Item", "Price List", "Item Price"] -class TestGetItemDetail(FrappeTestCase): +class TestGetItemDetail(IntegrationTestCase): def setUp(self): make_test_records("Price List") super().setUp() diff --git a/erpnext/stock/tests/test_utils.py b/erpnext/stock/tests/test_utils.py index bc646fae45c..2b90a592175 100644 --- a/erpnext/stock/tests/test_utils.py +++ b/erpnext/stock/tests/test_utils.py @@ -1,7 +1,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.stock.utils import scan_barcode @@ -57,7 +57,7 @@ class StockTestMixin: self.assertEqual(exp_value, act_value, msg=f"{k} doesn't match \n{exp_gle}\n{act_gle}") -class TestStockUtilities(FrappeTestCase, StockTestMixin): +class TestStockUtilities(IntegrationTestCase, StockTestMixin): def test_barcode_scanning(self): simple_item = self.make_item(properties={"barcodes": [{"barcode": "12399"}]}) self.assertEqual(scan_barcode("12399")["item_code"], simple_item.name) diff --git a/erpnext/stock/tests/test_valuation.py b/erpnext/stock/tests/test_valuation.py index 47b8f0b5cf5..df7c954918d 100644 --- a/erpnext/stock/tests/test_valuation.py +++ b/erpnext/stock/tests/test_valuation.py @@ -2,7 +2,7 @@ import json import unittest import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from hypothesis import given from hypothesis import strategies as st @@ -317,7 +317,7 @@ class TestLIFOValuation(unittest.TestCase): self.assertTotalValue(total_value) -class TestLIFOValuationSLE(FrappeTestCase): +class TestLIFOValuationSLE(IntegrationTestCase): ITEM_CODE = "_Test LIFO item" WAREHOUSE = "_Test Warehouse - _TC" diff --git a/erpnext/subcontracting/doctype/subcontracting_bom/test_subcontracting_bom.py b/erpnext/subcontracting/doctype/subcontracting_bom/test_subcontracting_bom.py index 9335ac8cba0..f94fc806199 100644 --- a/erpnext/subcontracting/doctype/subcontracting_bom/test_subcontracting_bom.py +++ b/erpnext/subcontracting/doctype/subcontracting_bom/test_subcontracting_bom.py @@ -2,10 +2,19 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSubcontractingBOM(FrappeTestCase): +class UnitTestSubcontractingBom(UnitTestCase): + """ + Unit tests for SubcontractingBom. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSubcontractingBOM(IntegrationTestCase): pass diff --git a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py index 0ae07993be8..aca315e00d1 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/test_subcontracting_order.py @@ -5,7 +5,7 @@ import copy from collections import defaultdict import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import flt from erpnext.buying.doctype.purchase_order.purchase_order import get_mapped_subcontracting_order @@ -32,7 +32,16 @@ from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order im ) -class TestSubcontractingOrder(FrappeTestCase): +class UnitTestSubcontractingOrder(UnitTestCase): + """ + Unit tests for SubcontractingOrder. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSubcontractingOrder(IntegrationTestCase): def setUp(self): make_subcontracted_items() make_raw_materials() diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py index 8ff5c8f27b0..b0355a1aeb4 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/test_subcontracting_receipt.py @@ -5,7 +5,7 @@ import copy import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_days, cint, flt, nowtime, today import erpnext @@ -40,7 +40,16 @@ from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order im ) -class TestSubcontractingReceipt(FrappeTestCase): +class UnitTestSubcontractingReceipt(UnitTestCase): + """ + Unit tests for SubcontractingReceipt. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSubcontractingReceipt(IntegrationTestCase): def setUp(self): make_subcontracted_items() make_raw_materials() @@ -372,7 +381,7 @@ class TestSubcontractingReceipt(FrappeTestCase): self.assertTrue(get_gl_entries("Subcontracting Receipt", scr.name)) frappe.db.set_single_value("Stock Settings", "use_serial_batch_fields", 1) - @change_settings("Stock Settings", {"use_serial_batch_fields": 0}) + @IntegrationTestCase.change_settings("Stock Settings", {"use_serial_batch_fields": 0}) def test_subcontracting_receipt_with_zero_service_cost(self): warehouse = "Stores - TCP1" service_items = [ @@ -1073,7 +1082,7 @@ class TestSubcontractingReceipt(FrappeTestCase): scr.cancel() self.assertTrue(scr.docstatus == 2) - @change_settings("Buying Settings", {"auto_create_purchase_receipt": 1}) + @IntegrationTestCase.change_settings("Buying Settings", {"auto_create_purchase_receipt": 1}) def test_auto_create_purchase_receipt(self): fg_item = "Subcontracted Item SA1" service_items = [ diff --git a/erpnext/tests/test_activation.py b/erpnext/tests/test_activation.py index b56e2332cf4..a2c62954252 100644 --- a/erpnext/tests/test_activation.py +++ b/erpnext/tests/test_activation.py @@ -1,9 +1,9 @@ -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.utilities.activation import get_level -class TestActivation(FrappeTestCase): +class TestActivation(IntegrationTestCase): def test_activation(self): levels = get_level() self.assertTrue(levels) diff --git a/erpnext/tests/test_perf.py b/erpnext/tests/test_perf.py index fc17b1dcbda..898e3115568 100644 --- a/erpnext/tests/test_perf.py +++ b/erpnext/tests/test_perf.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase INDEXED_FIELDS = { "Bin": ["item_code"], @@ -9,7 +9,7 @@ INDEXED_FIELDS = { } -class TestPerformance(FrappeTestCase): +class TestPerformance(IntegrationTestCase): def test_ensure_indexes(self): # These fields are not explicitly indexed BUT they are prefix in some # other composite index. If those are removed this test should be diff --git a/erpnext/tests/test_zform_loads.py b/erpnext/tests/test_zform_loads.py index 203a27eaf26..ef68c10273f 100644 --- a/erpnext/tests/test_zform_loads.py +++ b/erpnext/tests/test_zform_loads.py @@ -2,12 +2,12 @@ import frappe from frappe.desk.form.load import getdoc -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase from frappe.www.printview import get_html_and_style -class TestFormLoads(FrappeTestCase): - @change_settings("Print Settings", {"allow_print_for_cancelled": 1}) +class TestFormLoads(IntegrationTestCase): + @IntegrationTestCase.change_settings("Print Settings", {"allow_print_for_cancelled": 1}) def test_load(self): erpnext_modules = frappe.get_all("Module Def", filters={"app_name": "erpnext"}, pluck="name") doctypes = frappe.get_all(