From 48ba8b67bbf36ded287403ef433c3b890ae9f1be Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 10 Oct 2024 18:53:43 +0530 Subject: [PATCH 1/4] test: change of test utility --- .../overrides/test_account_settings.py | 4 +-- .../overrides/test_property_setter.py | 4 +-- .../audit_trail/overrides/test_version.py | 4 +-- .../bill_of_entry/test_bill_of_entry.py | 4 +-- .../e_invoice_log/test_e_invoice_log.py | 4 +-- .../e_waybill_log/test_e_waybill_log.py | 4 +-- .../doctype/gst_hsn_code/test_gst_hsn_code.py | 4 +-- .../test_gst_inward_supply.py | 4 +-- .../gst_return_log/test_gst_return_log.py | 4 +-- .../doctype/gst_settings/test_gst_settings.py | 4 +-- .../gst_india/doctype/gstin/test_gstin.py | 4 +-- .../doctype/gstr_1_beta/test_gstr_1_beta.py | 4 +-- .../gstr_3b_report/test_gstr_3b_report.py | 4 +-- .../gstr_import_log/test_gstr_import_log.py | 4 +-- .../gst_india/doctype/pan/test_pan.py | 4 +-- .../test_purchase_reconciliation_tool.py | 4 +-- .../overrides/test_advance_payment_entry.py | 4 +-- .../gst_india/overrides/test_company.py | 4 +-- .../overrides/test_ineligible_itc.py | 4 +-- .../overrides/test_item_tax_template.py | 4 +-- .../gst_india/overrides/test_party.py | 4 +-- .../overrides/test_purchase_invoice.py | 4 +-- .../gst_india/overrides/test_setup_wizard.py | 4 +-- .../test_subcontracting_transaction.py | 4 +-- .../gst_india/overrides/test_transaction.py | 12 ++++----- .../overrides/test_transaction_data.py | 4 +-- .../test_sales_register_beta.py | 4 +-- .../gst_india/report/gstr_1/test_gstr_1.py | 4 +-- .../utils/gstr_1/test_gstr_1_json_map.py | 26 +++++++++---------- .../gst_india/utils/gstr_2/test_gstr_2a.py | 4 +-- .../gst_india/utils/gstr_2/test_gstr_2b.py | 4 +-- .../gst_india/utils/test_e_invoice.py | 4 +-- .../gst_india/utils/test_e_waybill.py | 4 +-- .../gst_india/utils/test_utils.py | 4 +-- india_compliance/test_patches.py | 4 +-- 35 files changed, 85 insertions(+), 85 deletions(-) diff --git a/india_compliance/audit_trail/overrides/test_account_settings.py b/india_compliance/audit_trail/overrides/test_account_settings.py index 9ef0a6f86..6ba9b2065 100644 --- a/india_compliance/audit_trail/overrides/test_account_settings.py +++ b/india_compliance/audit_trail/overrides/test_account_settings.py @@ -1,10 +1,10 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestAccountsSettings(FrappeTestCase): +class TestAccountsSettings(IntegrationTestCase): def test_validate_change_in_enable_audit_trail_and_validate_delete_linked_ledger_entries( self, ): diff --git a/india_compliance/audit_trail/overrides/test_property_setter.py b/india_compliance/audit_trail/overrides/test_property_setter.py index f7680bb1a..897e0161a 100644 --- a/india_compliance/audit_trail/overrides/test_property_setter.py +++ b/india_compliance/audit_trail/overrides/test_property_setter.py @@ -1,10 +1,10 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestPropertySetter(FrappeTestCase): +class TestPropertySetter(IntegrationTestCase): def test_validate_property_setter_where_audit_trail_enabled_and_doc_is_protected( self, ): diff --git a/india_compliance/audit_trail/overrides/test_version.py b/india_compliance/audit_trail/overrides/test_version.py index 9940edb63..110e83fcb 100644 --- a/india_compliance/audit_trail/overrides/test_version.py +++ b/india_compliance/audit_trail/overrides/test_version.py @@ -1,12 +1,12 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.utils.tests import create_sales_invoice -class TestVersion(FrappeTestCase): +class TestVersion(IntegrationTestCase): def test_validate_version_where_audit_trail_enabled(self): # enable audit trail frappe.db.set_single_value("Accounts Settings", "enable_audit_trail", 1) diff --git a/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py b/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py index 6dad39e4b..113deb5e0 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py +++ b/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py @@ -5,7 +5,7 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import today from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import ( @@ -18,7 +18,7 @@ from india_compliance.gst_india.utils.tests import create_purchase_invoice -class TestBillofEntry(FrappeTestCase): +class TestBillofEntry(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/doctype/e_invoice_log/test_e_invoice_log.py b/india_compliance/gst_india/doctype/e_invoice_log/test_e_invoice_log.py index eab1960e2..004baefcd 100644 --- a/india_compliance/gst_india/doctype/e_invoice_log/test_e_invoice_log.py +++ b/india_compliance/gst_india/doctype/e_invoice_log/test_e_invoice_log.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TesteInvoiceLog(FrappeTestCase): +class TesteInvoiceLog(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/e_waybill_log/test_e_waybill_log.py b/india_compliance/gst_india/doctype/e_waybill_log/test_e_waybill_log.py index 3cf29d092..ff7be8a83 100644 --- a/india_compliance/gst_india/doctype/e_waybill_log/test_e_waybill_log.py +++ b/india_compliance/gst_india/doctype/e_waybill_log/test_e_waybill_log.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TesteWaybillLog(FrappeTestCase): +class TesteWaybillLog(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py b/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py index fe5a43d62..f9ba17d17 100644 --- a/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py +++ b/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py @@ -3,14 +3,14 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from india_compliance.gst_india.doctype.gst_hsn_code.gst_hsn_code import ( update_taxes_in_item_master, ) -class TestGSTHSNCode(FrappeTestCase): +class TestGSTHSNCode(IntegrationTestCase): @change_settings("GST Settings", {"validate_hsn_code": 0}) def test_validate_hsn_when_validate_hsn_code_disabled(self): doc = frappe.get_doc({"doctype": "GST HSN Code", "hsn_code": "1"}) diff --git a/india_compliance/gst_india/doctype/gst_inward_supply/test_gst_inward_supply.py b/india_compliance/gst_india/doctype/gst_inward_supply/test_gst_inward_supply.py index 39b556615..e44bc9345 100644 --- a/india_compliance/gst_india/doctype/gst_inward_supply/test_gst_inward_supply.py +++ b/india_compliance/gst_india/doctype/gst_inward_supply/test_gst_inward_supply.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestGSTInwardSupply(FrappeTestCase): +class TestGSTInwardSupply(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/gst_return_log/test_gst_return_log.py b/india_compliance/gst_india/doctype/gst_return_log/test_gst_return_log.py index e7c6d222c..504f70913 100644 --- a/india_compliance/gst_india/doctype/gst_return_log/test_gst_return_log.py +++ b/india_compliance/gst_india/doctype/gst_return_log/test_gst_return_log.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestGSTReturnLog(FrappeTestCase): +class TestGSTReturnLog(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py b/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py index 3f60af7d2..6b391a0ec 100644 --- a/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py +++ b/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py @@ -3,11 +3,11 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils.data import getdate -class TestGSTSettings(FrappeTestCase): +class TestGSTSettings(IntegrationTestCase): @change_settings("GST Settings", {"enable_api": 1}) def test_api_key_enabled(self): diff --git a/india_compliance/gst_india/doctype/gstin/test_gstin.py b/india_compliance/gst_india/doctype/gstin/test_gstin.py index d9b495641..8a36f3ee2 100644 --- a/india_compliance/gst_india/doctype/gstin/test_gstin.py +++ b/india_compliance/gst_india/doctype/gstin/test_gstin.py @@ -3,7 +3,7 @@ import responses from responses import matchers -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from india_compliance.gst_india.doctype.gstin.gstin import validate_gst_transporter_id @@ -24,7 +24,7 @@ } -class TestGSTIN(FrappeTestCase): +class TestGSTIN(IntegrationTestCase): @responses.activate @change_settings("GST Settings", {"validate_gstin_status": 1, "sandbox_mode": 0}) def test_validate_gst_transporter_id(self): diff --git a/india_compliance/gst_india/doctype/gstr_1_beta/test_gstr_1_beta.py b/india_compliance/gst_india/doctype/gstr_1_beta/test_gstr_1_beta.py index 67158cb74..32acff150 100644 --- a/india_compliance/gst_india/doctype/gstr_1_beta/test_gstr_1_beta.py +++ b/india_compliance/gst_india/doctype/gstr_1_beta/test_gstr_1_beta.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestGSTR1Beta(FrappeTestCase): +class TestGSTR1Beta(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/gstr_3b_report/test_gstr_3b_report.py b/india_compliance/gst_india/doctype/gstr_3b_report/test_gstr_3b_report.py index 25e93bfe5..f1d8ec21d 100644 --- a/india_compliance/gst_india/doctype/gstr_3b_report/test_gstr_3b_report.py +++ b/india_compliance/gst_india/doctype/gstr_3b_report/test_gstr_3b_report.py @@ -4,7 +4,7 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import getdate from india_compliance.gst_india.utils.tests import ( @@ -13,7 +13,7 @@ ) -class TestGSTR3BReport(FrappeTestCase): +class TestGSTR3BReport(IntegrationTestCase): def setUp(self): frappe.set_user("Administrator") filters = {"company": "_Test Indian Registered Company"} diff --git a/india_compliance/gst_india/doctype/gstr_import_log/test_gstr_import_log.py b/india_compliance/gst_india/doctype/gstr_import_log/test_gstr_import_log.py index de70f84ec..4914607cc 100644 --- a/india_compliance/gst_india/doctype/gstr_import_log/test_gstr_import_log.py +++ b/india_compliance/gst_india/doctype/gstr_import_log/test_gstr_import_log.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestGSTRImportLog(FrappeTestCase): +class TestGSTRImportLog(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/pan/test_pan.py b/india_compliance/gst_india/doctype/pan/test_pan.py index 2001bb7d2..b588283bb 100644 --- a/india_compliance/gst_india/doctype/pan/test_pan.py +++ b/india_compliance/gst_india/doctype/pan/test_pan.py @@ -2,8 +2,8 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestPAN(FrappeTestCase): +class TestPAN(IntegrationTestCase): pass diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py index 93dd228b2..e6a57dd15 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py @@ -5,7 +5,7 @@ import frappe from frappe.test_runner import make_test_objects -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import ( make_bill_of_entry, @@ -50,7 +50,7 @@ } -class TestPurchaseReconciliationTool(FrappeTestCase): +class TestPurchaseReconciliationTool(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/overrides/test_advance_payment_entry.py b/india_compliance/gst_india/overrides/test_advance_payment_entry.py index b7422cff2..21981ab61 100644 --- a/india_compliance/gst_india/overrides/test_advance_payment_entry.py +++ b/india_compliance/gst_india/overrides/test_advance_payment_entry.py @@ -3,7 +3,7 @@ from contextlib import contextmanager import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from erpnext.accounts.doctype.payment_entry.payment_entry import ( get_outstanding_reference_documents, ) @@ -47,7 +47,7 @@ def toggle_seperate_advance_accounting(): ) -class TestAdvancePaymentEntry(FrappeTestCase): +class TestAdvancePaymentEntry(IntegrationTestCase): EXPECTED_GL = [ {"account": "Cash - _TIRC", "debit": 590.0, "credit": 0.0}, {"account": "Debtors - _TIRC", "debit": 0.0, "credit": 500.0}, diff --git a/india_compliance/gst_india/overrides/test_company.py b/india_compliance/gst_india/overrides/test_company.py index c2fe84047..8190c4112 100644 --- a/india_compliance/gst_india/overrides/test_company.py +++ b/india_compliance/gst_india/overrides/test_company.py @@ -1,10 +1,10 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.overrides.company import get_tax_defaults -class TestCompanyFixtures(FrappeTestCase): +class TestCompanyFixtures(IntegrationTestCase): @classmethod def setUpClass(cls): frappe.db.savepoint("before_test_company") diff --git a/india_compliance/gst_india/overrides/test_ineligible_itc.py b/india_compliance/gst_india/overrides/test_ineligible_itc.py index 4254977f9..ac27d19d0 100644 --- a/india_compliance/gst_india/overrides/test_ineligible_itc.py +++ b/india_compliance/gst_india/overrides/test_ineligible_itc.py @@ -2,7 +2,7 @@ from contextlib import contextmanager import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import today from erpnext.controllers.sales_and_purchase_return import make_return_doc from erpnext.stock.doctype.purchase_receipt.purchase_receipt import ( @@ -101,7 +101,7 @@ def toggle_provisional_accounting(): ) -class TestIneligibleITC(FrappeTestCase): +class TestIneligibleITC(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/overrides/test_item_tax_template.py b/india_compliance/gst_india/overrides/test_item_tax_template.py index 64f0cb0d3..45626d2e5 100644 --- a/india_compliance/gst_india/overrides/test_item_tax_template.py +++ b/india_compliance/gst_india/overrides/test_item_tax_template.py @@ -1,7 +1,7 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.overrides.transaction import get_valid_accounts from india_compliance.gst_india.utils import get_gst_accounts_by_type @@ -10,7 +10,7 @@ # Validation of GST Rate -class TestTransaction(FrappeTestCase): +class TestTransaction(IntegrationTestCase): def test_item_tax_template_for_foreign_company(self): doc = create_item_tax_template( company="_Test Foreign Company", gst_rate=0, gst_treatment="Exempt" diff --git a/india_compliance/gst_india/overrides/test_party.py b/india_compliance/gst_india/overrides/test_party.py index 695e58b05..078c36751 100644 --- a/india_compliance/gst_india/overrides/test_party.py +++ b/india_compliance/gst_india/overrides/test_party.py @@ -1,8 +1,8 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestUtils(FrappeTestCase): +class TestUtils(IntegrationTestCase): def test_validate_new_party(self): party = frappe.new_doc( "Customer", customer_name="Resilient Tech", gstin="24AUTPV8831F1ZZ" diff --git a/india_compliance/gst_india/overrides/test_purchase_invoice.py b/india_compliance/gst_india/overrides/test_purchase_invoice.py index a251d9672..702c21155 100644 --- a/india_compliance/gst_india/overrides/test_purchase_invoice.py +++ b/india_compliance/gst_india/overrides/test_purchase_invoice.py @@ -1,11 +1,11 @@ import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from erpnext.accounts.doctype.account.test_account import create_account from india_compliance.gst_india.utils.tests import append_item, create_purchase_invoice -class TestPurchaseInvoice(FrappeTestCase): +class TestPurchaseInvoice(IntegrationTestCase): @change_settings("GST Settings", {"enable_overseas_transactions": 1}) def test_itc_classification(self): pinv = create_purchase_invoice( diff --git a/india_compliance/gst_india/overrides/test_setup_wizard.py b/india_compliance/gst_india/overrides/test_setup_wizard.py index acc8dc428..1e00cc199 100644 --- a/india_compliance/gst_india/overrides/test_setup_wizard.py +++ b/india_compliance/gst_india/overrides/test_setup_wizard.py @@ -1,8 +1,8 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestSetupWizard(FrappeTestCase): +class TestSetupWizard(IntegrationTestCase): def test_setup_wizard_with_valid_gstin(self): setup_company = "Wind Power LLP" company = frappe.get_doc("Company", setup_company) diff --git a/india_compliance/gst_india/overrides/test_subcontracting_transaction.py b/india_compliance/gst_india/overrides/test_subcontracting_transaction.py index 4749f1c5b..3498826a5 100644 --- a/india_compliance/gst_india/overrides/test_subcontracting_transaction.py +++ b/india_compliance/gst_india/overrides/test_subcontracting_transaction.py @@ -1,9 +1,9 @@ -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.utils.tests import create_transaction -class TestSubcontractingTransaction(FrappeTestCase): +class TestSubcontractingTransaction(IntegrationTestCase): def test_create_and_update_stock_entry(self): # Create a subcontracting transaction args = { diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index 756fadee7..8a2f82c99 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -4,7 +4,7 @@ from parameterized import parameterized_class import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import today from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import ( make_regional_gl_entries, @@ -50,7 +50,7 @@ # ("POS Invoice"), ], ) -class TestTransaction(FrappeTestCase): +class TestTransaction(IntegrationTestCase): @classmethod def setUpClass(cls): frappe.db.savepoint("before_test_transaction") @@ -924,7 +924,7 @@ def test_valid_item_tax_template(self): self.fail("Item Tax Template validation message found") -class TestQuotationTransaction(FrappeTestCase): +class TestQuotationTransaction(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -957,7 +957,7 @@ def get_lead(first_name): return lead.name -class TestSpecificTransactions(FrappeTestCase): +class TestSpecificTransactions(IntegrationTestCase): def test_copy_e_waybill_fields_from_dn_to_si(self): "Make sure e-Waybill fields are copied from Delivery Note to Sales Invoice" dn = create_transaction(doctype="Delivery Note", vehicle_no="GJ01AA1111") @@ -1017,7 +1017,7 @@ def create_tax_accounts(account_name): ).insert(ignore_if_duplicate=True) -class TestRegionalOverrides(FrappeTestCase): +class TestRegionalOverrides(IntegrationTestCase): @change_settings( "GST Settings", {"round_off_gst_values": 1}, @@ -1106,7 +1106,7 @@ def test_get_regional_address_details(self): self.assertTrue(party_details.get("taxes")) -class TestItemUpdate(FrappeTestCase): +class TestItemUpdate(IntegrationTestCase): DATA = { "customer": "_Test Unregistered Customer", "item_code": "_Test Trading Goods 1", diff --git a/india_compliance/gst_india/overrides/test_transaction_data.py b/india_compliance/gst_india/overrides/test_transaction_data.py index 7b7045894..60d29ffec 100644 --- a/india_compliance/gst_india/overrides/test_transaction_data.py +++ b/india_compliance/gst_india/overrides/test_transaction_data.py @@ -1,7 +1,7 @@ import re import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_to_date, getdate from frappe.utils.data import format_date @@ -13,7 +13,7 @@ from india_compliance.gst_india.utils.transaction_data import GSTTransactionData -class TestTransactionData(FrappeTestCase): +class TestTransactionData(IntegrationTestCase): @classmethod def setUpClass(cls): frappe.db.savepoint("before_test_transaction_data") diff --git a/india_compliance/gst_india/report/gst_sales_register_beta/test_sales_register_beta.py b/india_compliance/gst_india/report/gst_sales_register_beta/test_sales_register_beta.py index 836bb9856..2557bbc3e 100644 --- a/india_compliance/gst_india/report/gst_sales_register_beta/test_sales_register_beta.py +++ b/india_compliance/gst_india/report/gst_sales_register_beta/test_sales_register_beta.py @@ -1,4 +1,4 @@ -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import getdate from india_compliance.gst_india.report.gst_sales_register_beta.gst_sales_register_beta import ( @@ -643,7 +643,7 @@ ] -class TestSalesRegisterBeta(FrappeTestCase): +class TestSalesRegisterBeta(IntegrationTestCase): @classmethod @change_settings("GST Settings", {"enable_overseas_transactions": 1}) def setUpClass(cls): diff --git a/india_compliance/gst_india/report/gstr_1/test_gstr_1.py b/india_compliance/gst_india/report/gstr_1/test_gstr_1.py index 6d3def136..c5abc3d3c 100644 --- a/india_compliance/gst_india/report/gstr_1/test_gstr_1.py +++ b/india_compliance/gst_india/report/gstr_1/test_gstr_1.py @@ -1,5 +1,5 @@ import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import getdate from india_compliance.gst_india.report.gstr_1.gstr_1 import ( @@ -31,7 +31,7 @@ } -class TestGSTR1DocumentIssuedSummary(FrappeTestCase): +class TestGSTR1DocumentIssuedSummary(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/utils/gstr_1/test_gstr_1_json_map.py b/india_compliance/gst_india/utils/gstr_1/test_gstr_1_json_map.py index 19697220d..d38d5a694 100644 --- a/india_compliance/gst_india/utils/gstr_1/test_gstr_1_json_map.py +++ b/india_compliance/gst_india/utils/gstr_1/test_gstr_1_json_map.py @@ -1,6 +1,6 @@ import copy -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.doctype.gst_return_log.generate_gstr_1 import ( GenerateGSTR1, @@ -47,7 +47,7 @@ def process_mapped_data(data): )[0] -class TestB2B(FrappeTestCase): +class TestB2B(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -302,7 +302,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestB2CL(FrappeTestCase): +class TestB2CL(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -508,7 +508,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestExports(FrappeTestCase): +class TestExports(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -614,7 +614,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestB2CS(FrappeTestCase): +class TestB2CS(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -686,7 +686,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestNilRated(FrappeTestCase): +class TestNilRated(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -741,7 +741,7 @@ def test_convert_to_gov_data_format(self): self.assertDictEqual(self.json_data, output) -class TestCDNR(FrappeTestCase): +class TestCDNR(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -839,7 +839,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestCDNUR(FrappeTestCase): +class TestCDNUR(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -903,7 +903,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestHSNSUM(FrappeTestCase): +class TestHSNSUM(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -973,7 +973,7 @@ def test_convert_to_gov_data_format(self): self.assertDictEqual(self.json_data, output) -class TestAT(FrappeTestCase): +class TestAT(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -1089,7 +1089,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestTXPD(FrappeTestCase): +class TestTXPD(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -1207,7 +1207,7 @@ def test_convert_to_gov_data_format(self): self.assertListEqual(self.json_data, output) -class TestDOC_ISSUE(FrappeTestCase): +class TestDOC_ISSUE(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -1305,7 +1305,7 @@ def test_convert_to_gov_data_format(self): self.assertDictEqual(self.json_data, output) -class TestSUPECOM(FrappeTestCase): +class TestSUPECOM(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/utils/gstr_2/test_gstr_2a.py b/india_compliance/gst_india/utils/gstr_2/test_gstr_2a.py index 500e7eaa3..b694d658c 100644 --- a/india_compliance/gst_india/utils/gstr_2/test_gstr_2a.py +++ b/india_compliance/gst_india/utils/gstr_2/test_gstr_2a.py @@ -3,7 +3,7 @@ import frappe from frappe import parse_json, read_file -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import get_datetime from india_compliance.gst_india.utils import get_data_file_path @@ -43,7 +43,7 @@ def assertImportLog(self, category=None): ) -class TestGSTR2a(FrappeTestCase, TestGSTRMixin): +class TestGSTR2a(IntegrationTestCase, TestGSTRMixin): # Tests as per version 2.1 of GSTR2A Dt: 14-10-2020 @classmethod def setUpClass(cls): diff --git a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py index ec940318a..47f2a14cb 100644 --- a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py +++ b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py @@ -2,14 +2,14 @@ import frappe from frappe import parse_json, read_file -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.utils import get_data_file_path from india_compliance.gst_india.utils.gstr_2 import GSTRCategory, save_gstr_2b from india_compliance.gst_india.utils.gstr_2.test_gstr_2a import TestGSTRMixin -class TestGSTR2b(FrappeTestCase, TestGSTRMixin): +class TestGSTR2b(IntegrationTestCase, TestGSTRMixin): @classmethod def setUpClass(cls): cls.gstin = "01AABCE2207R1Z5" diff --git a/india_compliance/gst_india/utils/test_e_invoice.py b/india_compliance/gst_india/utils/test_e_invoice.py index 2bcc816fa..8f0bec80c 100644 --- a/india_compliance/gst_india/utils/test_e_invoice.py +++ b/india_compliance/gst_india/utils/test_e_invoice.py @@ -5,7 +5,7 @@ from responses import matchers import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import add_to_date, get_datetime, getdate, now_datetime from frappe.utils.data import format_date from erpnext.controllers.sales_and_purchase_return import make_return_doc @@ -24,7 +24,7 @@ from india_compliance.gst_india.utils.tests import append_item, create_sales_invoice -class TestEInvoice(FrappeTestCase): +class TestEInvoice(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/utils/test_e_waybill.py b/india_compliance/gst_india/utils/test_e_waybill.py index 09187fd1d..b7055666b 100644 --- a/india_compliance/gst_india/utils/test_e_waybill.py +++ b/india_compliance/gst_india/utils/test_e_waybill.py @@ -8,7 +8,7 @@ from responses import matchers import frappe -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, change_settings from frappe.utils import add_to_date, get_datetime, now_datetime, today from frappe.utils.data import format_date from frappe.www.printview import get_html_and_style @@ -41,7 +41,7 @@ DATE_FORMAT = "dd/mm/yyyy" -class TestEWaybill(FrappeTestCase): +class TestEWaybill(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/india_compliance/gst_india/utils/test_utils.py b/india_compliance/gst_india/utils/test_utils.py index cea70bd5f..ababd23d9 100644 --- a/india_compliance/gst_india/utils/test_utils.py +++ b/india_compliance/gst_india/utils/test_utils.py @@ -2,11 +2,11 @@ from unittest.mock import patch import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import getdate -class TestUtils(FrappeTestCase): +class TestUtils(IntegrationTestCase): @classmethod def setUpClass(cls): diff --git a/india_compliance/test_patches.py b/india_compliance/test_patches.py index 5d4143853..2f1a4e4a2 100644 --- a/india_compliance/test_patches.py +++ b/india_compliance/test_patches.py @@ -1,11 +1,11 @@ import frappe from frappe.modules.patch_handler import get_patches_from_app -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from india_compliance.install import POST_INSTALL_PATCHES -class TestPatches(FrappeTestCase): +class TestPatches(IntegrationTestCase): def test_post_install_patch_exists(self): for patch in POST_INSTALL_PATCHES: self.assertTrue( From c67e9aa9d5c80feca5ab59e9e1bee717a1b50cca Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Fri, 11 Oct 2024 13:18:41 +0530 Subject: [PATCH 2/4] test: change command for running tests --- .github/workflows/server-tests.yml | 2 +- india_compliance/tests/test_records.json | 48 ++---------------------- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests.yml index aa1c596c9..909486ee8 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests.yml @@ -109,7 +109,7 @@ jobs: BRANCH_TO_CLONE: ${{ env.BRANCH }} - name: Run Tests - run: cd ~/frappe-bench/ && bench --site test_site run-tests --app ${{ env.APP_NAME }} --coverage + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app ${{ env.APP_NAME }} --with-coverage env: TYPE: server diff --git a/india_compliance/tests/test_records.json b/india_compliance/tests/test_records.json index ba91900f2..0b9e05f1b 100644 --- a/india_compliance/tests/test_records.json +++ b/india_compliance/tests/test_records.json @@ -43,6 +43,7 @@ "item_name": "_Test Trading Goods 1", "valuation_rate": 100, "gst_hsn_code": "61149090", + "stock_uom": "Nos", "uoms": [ { "conversion_factor": 1, @@ -70,6 +71,7 @@ "item_name": "_Test Non GST Item", "valuation_rate": 100, "gst_hsn_code": "27131100", + "stock_uom": "Nos", "uoms": [ { "conversion_factor": 1, @@ -102,6 +104,7 @@ "item_name": "_Test Nil Rated Item", "valuation_rate": 100, "gst_hsn_code": "61149090", + "stock_uom": "Nos", "item_defaults": [ { "company": "_Test Indian Registered Company", @@ -129,6 +132,7 @@ "valuation_rate": 100, "item_group": "Services", "gst_hsn_code": "999900", + "stock_uom": "Nos", "uoms": [ { "conversion_factor": 1, @@ -452,49 +456,5 @@ } ] } - ], - "POS Profile": [ - { - "name": "_Test POS Profile", - "company": "_Test Indian Registered Company", - "warehouse": "Stores - _TIRC", - "write_off_account": "Write Off - _TIRC", - "write_off_cost_center": "Main - _TIRC", - "payments": [ - { - "name": "tirc", - "mode_of_payment": "Cash", - "default": 1 - } - ] - }, - { - "name": "_Test POS Profile 2", - "company": "_Test Indian Unregistered Company", - "warehouse": "Stores - _TIUC", - "write_off_account": "Write Off - _TIUC", - "write_off_cost_center": "Main - _TIUC", - "payments": [ - { - "name": "tiuc", - "mode_of_payment": "Cash", - "default": 1 - } - ] - }, - { - "name": "_Test POS Profile 3", - "company": "_Test Foreign Company", - "warehouse": "Stores - _TFC", - "write_off_account": "Write Off - _TFC", - "write_off_cost_center": "Main - _TFC", - "payments": [ - { - "name": "tfc", - "mode_of_payment": "Cash", - "default": 1 - } - ] - } ] } From 9d7ce3395c92ffe3d3f8a0c05037999438beb053 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 14 Oct 2024 09:45:47 +0530 Subject: [PATCH 3/4] test: property setters removed when changed to default --- .../audit_trail/overrides/test_property_setter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/india_compliance/audit_trail/overrides/test_property_setter.py b/india_compliance/audit_trail/overrides/test_property_setter.py index 897e0161a..1346306bf 100644 --- a/india_compliance/audit_trail/overrides/test_property_setter.py +++ b/india_compliance/audit_trail/overrides/test_property_setter.py @@ -9,6 +9,15 @@ def test_validate_property_setter_where_audit_trail_enabled_and_doc_is_protected self, ): frappe.db.set_single_value("Accounts Settings", "enable_audit_trail", 1) + frappe.db.delete( + "Property Setter", + { + "doctype_or_field": "DocType", + "doc_type": "Purchase Invoice", + "property": "track_changes", + }, + ) + doc = frappe.get_doc( { "doctype": "Property Setter", From 98e77f4e67aed2359eaa9efa19ce99378c2b432c Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 14 Oct 2024 10:49:23 +0530 Subject: [PATCH 4/4] test: fix other dependencies for test cases --- .../doctype/bill_of_entry/test_bill_of_entry.py | 3 +++ .../gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py | 7 +++++++ .../gst_india/doctype/gst_settings/test_gst_settings.py | 6 ++++++ india_compliance/gst_india/doctype/gstin/test_gstin.py | 8 ++++++++ .../test_purchase_reconciliation_tool.py | 5 ++++- .../gst_india/overrides/test_sales_invoice.py | 5 ++--- .../test_hsn_wise_summary_of_outward_supplies.py | 9 ++------- india_compliance/gst_india/utils/test_gstin_info.py | 4 ++-- india_compliance/tests/__init__.py | 2 +- 9 files changed, 35 insertions(+), 14 deletions(-) diff --git a/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py b/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py index 113deb5e0..0fd56b479 100644 --- a/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py +++ b/india_compliance/gst_india/doctype/bill_of_entry/test_bill_of_entry.py @@ -21,6 +21,9 @@ class TestBillofEntry(IntegrationTestCase): @classmethod def setUpClass(cls): + # don't create test objects + frappe.local.test_objects["Bill of Entry"] = [] + super().setUpClass() frappe.db.set_single_value("GST Settings", "enable_overseas_transactions", 1) diff --git a/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py b/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py index f9ba17d17..115ece33d 100644 --- a/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py +++ b/india_compliance/gst_india/doctype/gst_hsn_code/test_gst_hsn_code.py @@ -11,6 +11,13 @@ class TestGSTHSNCode(IntegrationTestCase): + @classmethod + def setUpClass(cls): + # don't create test objects + frappe.local.test_objects["GST HSN Code"] = [] + + super().setUpClass() + @change_settings("GST Settings", {"validate_hsn_code": 0}) def test_validate_hsn_when_validate_hsn_code_disabled(self): doc = frappe.get_doc({"doctype": "GST HSN Code", "hsn_code": "1"}) diff --git a/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py b/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py index 6b391a0ec..cadab4640 100644 --- a/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py +++ b/india_compliance/gst_india/doctype/gst_settings/test_gst_settings.py @@ -8,6 +8,12 @@ class TestGSTSettings(IntegrationTestCase): + @classmethod + def setUpClass(cls): + # don't create test objects + frappe.local.test_objects["GST Settings"] = [] + + super().setUpClass() @change_settings("GST Settings", {"enable_api": 1}) def test_api_key_enabled(self): diff --git a/india_compliance/gst_india/doctype/gstin/test_gstin.py b/india_compliance/gst_india/doctype/gstin/test_gstin.py index 8a36f3ee2..7c575314c 100644 --- a/india_compliance/gst_india/doctype/gstin/test_gstin.py +++ b/india_compliance/gst_india/doctype/gstin/test_gstin.py @@ -3,6 +3,7 @@ import responses from responses import matchers +import frappe from frappe.tests import IntegrationTestCase, change_settings from india_compliance.gst_india.doctype.gstin.gstin import validate_gst_transporter_id @@ -25,6 +26,13 @@ class TestGSTIN(IntegrationTestCase): + @classmethod + def setUpClass(cls): + # don't create test objects + frappe.local.test_objects["GSTIN"] = [] + + super().setUpClass() + @responses.activate @change_settings("GST Settings", {"validate_gstin_status": 1, "sandbox_mode": 0}) def test_validate_gst_transporter_id(self): diff --git a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py index e6a57dd15..6f10417b1 100644 --- a/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py +++ b/india_compliance/gst_india/doctype/purchase_reconciliation_tool/test_purchase_reconciliation_tool.py @@ -4,8 +4,8 @@ import datetime import frappe -from frappe.test_runner import make_test_objects from frappe.tests import IntegrationTestCase +from frappe.tests.utils import make_test_objects from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import ( make_bill_of_entry, @@ -53,6 +53,9 @@ class TestPurchaseReconciliationTool(IntegrationTestCase): @classmethod def setUpClass(cls): + # don't create test objects + frappe.local.test_objects["Purchase Reconciliation Tool"] = [] + super().setUpClass() # create 2023-2024 fiscal year diff --git a/india_compliance/gst_india/overrides/test_sales_invoice.py b/india_compliance/gst_india/overrides/test_sales_invoice.py index 010f6df56..da2c3285f 100644 --- a/india_compliance/gst_india/overrides/test_sales_invoice.py +++ b/india_compliance/gst_india/overrides/test_sales_invoice.py @@ -1,11 +1,10 @@ -import unittest - import frappe +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.utils import validate_invoice_number -class TestSalesInvoice(unittest.TestCase): +class TestSalesInvoice(IntegrationTestCase): def test_validate_invoice_number(self): posting_date = "2021-05-01" diff --git a/india_compliance/gst_india/report/hsn_wise_summary_of_outward_supplies/test_hsn_wise_summary_of_outward_supplies.py b/india_compliance/gst_india/report/hsn_wise_summary_of_outward_supplies/test_hsn_wise_summary_of_outward_supplies.py index 1684039c7..e39b5405a 100644 --- a/india_compliance/gst_india/report/hsn_wise_summary_of_outward_supplies/test_hsn_wise_summary_of_outward_supplies.py +++ b/india_compliance/gst_india/report/hsn_wise_summary_of_outward_supplies/test_hsn_wise_summary_of_outward_supplies.py @@ -2,9 +2,8 @@ # For license information, please see license.txt -from unittest import TestCase - import frappe +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.report.hsn_wise_summary_of_outward_supplies.hsn_wise_summary_of_outward_supplies import ( execute as run_report, @@ -12,11 +11,7 @@ from india_compliance.gst_india.utils.tests import append_item, create_sales_invoice -class TestHSNWiseSummaryReport(TestCase): - @classmethod - def setUpClass(cls): - pass - +class TestHSNWiseSummaryReport(IntegrationTestCase): @classmethod def tearDownClass(cls): frappe.db.rollback() diff --git a/india_compliance/gst_india/utils/test_gstin_info.py b/india_compliance/gst_india/utils/test_gstin_info.py index c8ad1a6a2..715e56767 100644 --- a/india_compliance/gst_india/utils/test_gstin_info.py +++ b/india_compliance/gst_india/utils/test_gstin_info.py @@ -1,12 +1,12 @@ -import unittest from unittest.mock import Mock, patch import frappe +from frappe.tests import IntegrationTestCase from india_compliance.gst_india.utils.gstin_info import get_gstin_info -class TestGstinInfo(unittest.TestCase): +class TestGstinInfo(IntegrationTestCase): MOCK_GSTIN_INFO = frappe._dict( { "adadr": [ diff --git a/india_compliance/tests/__init__.py b/india_compliance/tests/__init__.py index a563ed41e..bae5ec311 100644 --- a/india_compliance/tests/__init__.py +++ b/india_compliance/tests/__init__.py @@ -2,7 +2,7 @@ import frappe from frappe.desk.page.setup_wizard.setup_wizard import setup_complete -from frappe.test_runner import make_test_objects +from frappe.tests.utils import make_test_objects from frappe.utils import getdate from frappe.utils.nestedset import get_root_of from erpnext.accounts.utils import get_fiscal_year