Skip to content

Commit

Permalink
refactor: clarify test record module iface (treewide)
Browse files Browse the repository at this point in the history
This aims at reducing the deprecation warning pressure on a standard Erpnext test run.
  • Loading branch information
blaggacao authored Oct 10, 2024
2 parents 2fc4f86 + ed5bead commit 922b5d1
Show file tree
Hide file tree
Showing 52 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/account/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account

test_dependencies = ["Company"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company"]


class TestAccount(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice

test_dependencies = ["Cost Center", "Location", "Warehouse", "Department"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Cost Center", "Location", "Warehouse", "Department"]


class TestAccountingDimension(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError

test_dependencies = ["Location", "Cost Center", "Department"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Location", "Cost Center", "Department"]


class TestAccountingDimensionFilter(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice

test_dependencies = ["Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]


class TestAccountingPeriod(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.tests.utils import if_lending_app_installed

test_dependencies = ["Item", "Cost Center"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Cost Center"]


class UnitTestBankTransaction(UnitTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/budget/test_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from erpnext.accounts.utils import get_fiscal_year
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order

test_dependencies = ["Monthly Distribution"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Monthly Distribution"]


class TestBudget(IntegrationTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/coupon_code/test_coupon_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order

test_dependencies = ["Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]


def test_create_test_data():
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/dunning/test_dunning.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
create_sales_invoice_against_cost_center,
)

test_dependencies = ["Company", "Cost Center"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company", "Cost Center"]


class UnitTestDunning(UnitTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from frappe.tests import IntegrationTestCase
from frappe.utils import now_datetime

test_ignore = ["Company"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Company"]


class TestFiscalYear(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
get_temporary_opening_account,
)

test_dependencies = ["Customer", "Supplier", "Accounting Dimension"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Customer", "Supplier", "Accounting Dimension"]


class UnitTestOpeningInvoiceCreationTool(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.setup.doctype.employee.test_employee import make_employee

test_dependencies = ["Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]


class UnitTestPaymentEntry(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# test_records = frappe.get_test_records('Payment Gateway Account')

test_ignore = ["Payment Gateway"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Payment Gateway"]


class TestPaymentGatewayAccount(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
from erpnext.stock.doctype.item.test_item import create_item

test_dependencies = ["Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]


class UnitTestPaymentReconciliation(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.setup.utils import get_exchange_rate

test_dependencies = ["Currency Exchange", "Journal Entry", "Contact", "Address"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Currency Exchange", "Journal Entry", "Contact", "Address"]

PAYMENT_URL = "https://example.com/payment"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,5 @@ def create_cost_center(cc_name):
return costcenter.name


test_dependencies = ["Customer", "Cost Center"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Customer", "Cost Center"]
test_records = frappe.get_test_records("Period Closing Voucher")
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/pos_profile/test_pos_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)
from erpnext.stock.get_item_details import get_pos_profile

test_dependencies = ["Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]


class TestPOSProfile(IntegrationTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ def test_ignore_pricing_rule_for_debit_note(self):
pi.cancel()


test_dependencies = ["UTM Campaign"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["UTM Campaign"]


def make_pricing_rule(**args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction
from erpnext.stock.tests.test_utils import StockTestMixin

test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"]
test_ignore = ["Serial No"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Serial No"]


class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4356,7 +4356,7 @@ def create_sales_invoice_against_cost_center(**args):
return si


test_dependencies = ["Journal Entry", "Contact", "Address"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Journal Entry", "Contact", "Address"]
test_records = frappe.get_test_records("Sales Invoice")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from erpnext.accounts.doctype.share_transfer.share_transfer import ShareDontExists

test_dependencies = ["Share Type", "Shareholder"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Share Type", "Shareholder"]


class TestShareTransfer(IntegrationTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/subscription/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from erpnext.accounts.doctype.subscription.subscription import get_prorata_factor

test_dependencies = ("UOM", "Item Group", "Item")
EXTRA_TEST_RECORD_DEPENDENCIES = ("UOM", "Item Group", "Item")


class UnitTestSubscription(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from erpnext.accounts.utils import get_fiscal_year
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice

test_dependencies = ["Supplier Group", "Customer Group"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Supplier Group", "Customer Group"]


class UnitTestTaxWithholdingCategory(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
COMPANY = "_Test Company 6"
COMPANY_SHORT_NAME = "_TC6"

test_dependencies = ["Company"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company"]


class TestBalanceSheet(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
get_mode_of_payments,
)

test_dependencies = ["Sales Invoice"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Sales Invoice"]


class TestSalesPaymentSummary(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,6 @@ def get_requested_qty(item_code="_Test Item", warehouse="_Test Warehouse - _TC")
return flt(frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, "indented_qty"))


test_dependencies = ["BOM", "Item Price"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["BOM", "Item Price"]

test_records = frappe.get_test_records("Purchase Order")
2 changes: 1 addition & 1 deletion erpnext/buying/doctype/supplier/test_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from erpnext.controllers.website_list_for_contact import get_customers_suppliers
from erpnext.exceptions import PartyDisabled

test_dependencies = ["Payment Term", "Payment Terms Template"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Payment Term", "Payment Terms Template"]
test_records = frappe.get_test_records("Supplier")

from frappe.tests import IntegrationTestCase, UnitTestCase
Expand Down
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/bom/test_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)

test_records = frappe.get_test_records("BOM")
test_dependencies = ["Item", "Quality Inspection Template"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Quality Inspection Template"]


class UnitTestBom(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
from erpnext.stock.utils import get_bin

test_dependencies = ["BOM"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["BOM"]


class UnitTestWorkOrder(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
check_if_within_operating_hours,
)

test_dependencies = ["Warehouse"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Warehouse"]
test_records = frappe.get_test_records("Workstation")
make_test_records("Workstation")

Expand Down
2 changes: 1 addition & 1 deletion erpnext/projects/doctype/project/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order

test_records = frappe.get_test_records("Project")
test_ignore = ["Sales Order"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Sales Order"]


class UnitTestProject(UnitTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class TestProjectUpdate(IntegrationTestCase):


test_records = frappe.get_test_records("Project Update")
test_ignore = ["Sales Order"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Sales Order"]
2 changes: 1 addition & 1 deletion erpnext/regional/report/uae_vat_201/test_uae_vat_201.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from erpnext.stock.doctype.warehouse.test_warehouse import get_warehouse_account

test_dependencies = ["Territory", "Customer Group", "Supplier Group", "Item"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Territory", "Customer Group", "Supplier Group", "Item"]


class TestUaeVat201(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions erpnext/selling/doctype/customer/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
)
from erpnext.tests.utils import create_test_contact_and_address

test_ignore = ["Price List"]
test_dependencies = ["Payment Term", "Payment Terms Template"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Price List"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Payment Term", "Payment Terms Template"]
test_records = frappe.get_test_records("Customer")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from erpnext.controllers.queries import item_query

test_dependencies = ["Item", "Customer", "Supplier"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Customer", "Supplier"]


def create_party_specific_item(**args):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/selling/doctype/quotation/test_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from erpnext.controllers.accounts_controller import InvalidQtyError

test_dependencies = ["Product Bundle"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Product Bundle"]


class UnitTestQuotation(UnitTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/selling/doctype/sales_order/test_sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,7 @@ def get_reserved_qty(item_code="_Test Item", warehouse="_Test Warehouse - _TC"):
return flt(frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, "reserved_qty"))


test_dependencies = ["Currency Exchange"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Currency Exchange"]


def make_sales_order_workflow():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
)
from erpnext.stock.doctype.item.test_item import create_item

test_dependencies = ["Sales Order", "Item", "Sales Invoice", "Payment Terms Template", "Customer"]
EXTRA_TEST_RECORD_DEPENDENCIES = [
"Sales Order",
"Item",
"Sales Invoice",
"Payment Terms Template",
"Customer",
]


class TestPaymentTermsStatusForSalesOrder(IntegrationTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from erpnext.selling.report.sales_order_analysis.sales_order_analysis import execute
from erpnext.stock.doctype.item.test_item import create_item

test_dependencies = ["Sales Order", "Item", "Sales Invoice", "Delivery Note"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Sales Order", "Item", "Sales Invoice", "Delivery Note"]


class TestSalesOrderAnalysis(IntegrationTestCase):
Expand Down
10 changes: 8 additions & 2 deletions erpnext/setup/doctype/company/test_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
)
from erpnext.setup.doctype.company.company import get_default_company_address

test_ignore = ["Account", "Cost Center", "Payment Terms Template", "Salary Component", "Warehouse"]
test_dependencies = ["Fiscal Year"]
IGNORE_TEST_RECORD_DEPENDENCIES = [
"Account",
"Cost Center",
"Payment Terms Template",
"Salary Component",
"Warehouse",
]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Fiscal Year"]
test_records = frappe.get_test_records("Company")


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

test_ignore = ["Price List"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Price List"]


import frappe
Expand Down
2 changes: 1 addition & 1 deletion erpnext/setup/doctype/department/test_department.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import frappe
from frappe.tests import IntegrationTestCase

test_ignore = ["Leave Block List"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Leave Block List"]


class TestDepartment(IntegrationTestCase):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/setup/doctype/sales_partner/test_sales_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

test_records = frappe.get_test_records("Sales Partner")

test_ignore = ["Item Group"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Item Group"]
4 changes: 2 additions & 2 deletions erpnext/setup/doctype/sales_person/test_sales_person.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

test_dependencies = ["Employee"]
EXTRA_TEST_RECORD_DEPENDENCIES = ["Employee"]

import frappe

test_records = frappe.get_test_records("Sales Person")

test_ignore = ["Item Group"]
IGNORE_TEST_RECORD_DEPENDENCIES = ["Item Group"]
Loading

0 comments on commit 922b5d1

Please sign in to comment.