mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
refactor: replace IntegrationTestCase with ERPNextTestCase repo-wide
- import ERPNextTestSuite - use it on test class
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import flt
|
||||
|
||||
from erpnext.accounts.party import get_due_date
|
||||
@@ -15,10 +14,10 @@ from erpnext.selling.doctype.customer.customer import (
|
||||
get_customer_outstanding,
|
||||
parse_full_name,
|
||||
)
|
||||
from erpnext.tests.utils import create_test_contact_and_address
|
||||
from erpnext.tests.utils import ERPNextTestSuite, create_test_contact_and_address
|
||||
|
||||
|
||||
class TestCustomer(IntegrationTestCase):
|
||||
class TestCustomer(ERPNextTestSuite):
|
||||
def tearDown(self):
|
||||
set_credit_limit("_Test Customer", "_Test Company", 0)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# See license.txt
|
||||
import unittest
|
||||
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestInstallationNote(IntegrationTestCase):
|
||||
class TestInstallationNote(ERPNextTestSuite):
|
||||
pass
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# See license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
from erpnext.controllers.queries import item_query
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
def create_party_specific_item(**args):
|
||||
@@ -16,7 +16,7 @@ def create_party_specific_item(**args):
|
||||
psi.insert()
|
||||
|
||||
|
||||
class TestPartySpecificItem(IntegrationTestCase):
|
||||
class TestPartySpecificItem(ERPNextTestSuite):
|
||||
def setUp(self):
|
||||
self.customer = frappe.get_last_doc("Customer")
|
||||
self.supplier = frappe.get_last_doc("Supplier")
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase, change_settings
|
||||
from frappe.tests import change_settings
|
||||
from frappe.utils import add_days, add_months, flt, getdate, nowdate
|
||||
|
||||
from erpnext.controllers.accounts_controller import InvalidQtyError, update_child_qty_rate
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
from erpnext.setup.utils import get_exchange_rate
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestQuotation(IntegrationTestCase):
|
||||
class TestQuotation(ERPNextTestSuite):
|
||||
def test_update_child_quotation_add_item(self):
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
|
||||
@@ -180,7 +180,7 @@ class TestQuotation(IntegrationTestCase):
|
||||
|
||||
self.assertTrue(quotation.payment_schedule)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings",
|
||||
{"automatically_fetch_payment_terms": 1},
|
||||
)
|
||||
@@ -324,7 +324,7 @@ class TestQuotation(IntegrationTestCase):
|
||||
sales_order.delivery_date = nowdate()
|
||||
sales_order.insert()
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings",
|
||||
{
|
||||
"add_taxes_from_item_tax_template": 0,
|
||||
@@ -874,7 +874,7 @@ class TestQuotation(IntegrationTestCase):
|
||||
quotation.items[0].conversion_factor = 2.23
|
||||
self.assertRaises(frappe.ValidationError, quotation.save)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings",
|
||||
{"add_taxes_from_item_tax_template": 1, "add_taxes_from_taxes_and_charges_template": 0},
|
||||
)
|
||||
@@ -942,7 +942,7 @@ class TestQuotation(IntegrationTestCase):
|
||||
self.assertEqual(quotation.rounding_adjustment, 0)
|
||||
self.assertEqual(quotation.rounded_total, 0)
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"allow_zero_qty_in_quotation": 1})
|
||||
@ERPNextTestSuite.change_settings("Selling Settings", {"allow_zero_qty_in_quotation": 1})
|
||||
def test_so_from_zero_qty_quotation(self):
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
@@ -1074,7 +1074,7 @@ class TestQuotation(IntegrationTestCase):
|
||||
quotation.reload()
|
||||
self.assertEqual(quotation.status, "Open")
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings",
|
||||
{"automatically_fetch_payment_terms": 1},
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ 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 import IntegrationTestCase, change_settings
|
||||
from frappe.utils import add_days, flt, getdate, nowdate, today
|
||||
from frappe.tests import change_settings
|
||||
from frappe.utils import add_days, flt, nowdate, today
|
||||
|
||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||
from erpnext.controllers.accounts_controller import InvalidQtyError, get_due_date, update_child_qty_rate
|
||||
@@ -32,9 +32,10 @@ from erpnext.selling.doctype.sales_order.sales_order import (
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
from erpnext.stock.get_item_details import get_bin_details
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
class TestSalesOrder(AccountsTestMixin, ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
@@ -57,7 +58,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
frappe.db.rollback()
|
||||
frappe.set_user("Administrator")
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Stock Settings",
|
||||
{
|
||||
"auto_insert_price_list_rate_if_missing": 1,
|
||||
@@ -144,7 +145,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
so.reload()
|
||||
self.assertEqual(so.status, "Completed")
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"allow_negative_rates_for_items": 1})
|
||||
@ERPNextTestSuite.change_settings("Selling Settings", {"allow_negative_rates_for_items": 1})
|
||||
def test_sales_order_with_negative_rate(self):
|
||||
"""
|
||||
Test if negative rate is allowed in Sales Order via doc submission and update items
|
||||
@@ -265,7 +266,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
so.load_from_db()
|
||||
self.assertEqual(so.per_billed, 0)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings", {"automatically_fetch_payment_terms": 1}
|
||||
) # Enable auto fetch
|
||||
def test_make_sales_invoice_with_terms(self):
|
||||
@@ -296,7 +297,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
si1 = make_sales_invoice(so.name)
|
||||
self.assertEqual(len(si1.get("items")), 0)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings", {"automatically_fetch_payment_terms": 1}
|
||||
) # Enable auto fetch
|
||||
def test_auto_fetch_terms_enable(self):
|
||||
@@ -312,7 +313,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings", {"automatically_fetch_payment_terms": 0}
|
||||
) # Disable auto fetch
|
||||
def test_auto_fetch_terms_disable(self):
|
||||
@@ -1544,7 +1545,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
|
||||
self.assertRaises(frappe.LinkExistsError, so_doc.cancel)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1}
|
||||
)
|
||||
def test_advance_paid_upon_payment_cancellation(self):
|
||||
@@ -1801,7 +1802,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
so.load_from_db()
|
||||
self.assertRaises(frappe.LinkExistsError, so.cancel)
|
||||
|
||||
@IntegrationTestCase.change_settings("Accounts Settings", {"automatically_fetch_payment_terms": 1})
|
||||
@ERPNextTestSuite.change_settings("Accounts Settings", {"automatically_fetch_payment_terms": 1})
|
||||
def test_payment_terms_are_fetched_when_creating_sales_invoice(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
|
||||
create_payment_terms_template,
|
||||
@@ -2133,7 +2134,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
self.assertEqual(len(dn.packed_items), 1)
|
||||
self.assertEqual(dn.items[0].item_code, "_Test Product Bundle Item Partial 2")
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"editable_bundle_item_rates": 1})
|
||||
@ERPNextTestSuite.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"
|
||||
@@ -2471,7 +2472,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
|
||||
self.assertRaises(frappe.ValidationError, so1.update_status, "Draft")
|
||||
|
||||
@IntegrationTestCase.change_settings("Stock Settings", {"enable_stock_reservation": True})
|
||||
@ERPNextTestSuite.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)
|
||||
@@ -2585,7 +2586,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
sre_doc.reload()
|
||||
self.assertTrue(sre_doc.status == "Delivered")
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"allow_zero_qty_in_sales_order": 1})
|
||||
@ERPNextTestSuite.change_settings("Selling Settings", {"allow_zero_qty_in_sales_order": 1})
|
||||
def test_deliver_zero_qty_purchase_order(self):
|
||||
"""
|
||||
Test the flow of a Unit Price SO and DN creation against it until completion.
|
||||
@@ -2633,7 +2634,7 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
|
||||
self.assertEqual(so.per_delivered, 100.0)
|
||||
self.assertEqual(so.status, "To Bill")
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"allow_zero_qty_in_sales_order": 1})
|
||||
@ERPNextTestSuite.change_settings("Selling Settings", {"allow_zero_qty_in_sales_order": 1})
|
||||
def test_bill_zero_qty_sales_order(self):
|
||||
so = make_sales_order(qty=0)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# See license.txt
|
||||
import unittest
|
||||
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesPartnerType(IntegrationTestCase):
|
||||
class TestSalesPartnerType(ERPNextTestSuite):
|
||||
pass
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSellingSettings(IntegrationTestCase):
|
||||
class TestSellingSettings(ERPNextTestSuite):
|
||||
def test_defaults_populated(self):
|
||||
# Setup default values are not populated on migrate, this test checks
|
||||
# if setup was completed correctly
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import datetime
|
||||
|
||||
import frappe
|
||||
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
|
||||
@@ -10,9 +9,10 @@ from erpnext.selling.report.payment_terms_status_for_sales_order.payment_terms_s
|
||||
execute,
|
||||
)
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestPaymentTermsStatusForSalesOrder(IntegrationTestCase):
|
||||
class TestPaymentTermsStatusForSalesOrder(ERPNextTestSuite):
|
||||
def tearDown(self):
|
||||
frappe.db.rollback()
|
||||
|
||||
@@ -137,7 +137,7 @@ class TestPaymentTermsStatusForSalesOrder(IntegrationTestCase):
|
||||
)
|
||||
doc.insert()
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
@ERPNextTestSuite.change_settings(
|
||||
"Accounts Settings", allow_multi_currency_invoices_against_single_party_account=1
|
||||
)
|
||||
def test_02_alternate_currency(self):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import add_months, nowdate
|
||||
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_material_request
|
||||
@@ -10,9 +9,10 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde
|
||||
from erpnext.selling.report.pending_so_items_for_purchase_request.pending_so_items_for_purchase_request import (
|
||||
execute,
|
||||
)
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestPendingSOItemsForPurchaseRequest(IntegrationTestCase):
|
||||
class TestPendingSOItemsForPurchaseRequest(ERPNextTestSuite):
|
||||
def test_result_for_partial_material_request(self):
|
||||
so = make_sales_order()
|
||||
mr = make_material_request(so.name)
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
|
||||
import frappe
|
||||
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
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestAnalytics(IntegrationTestCase):
|
||||
class TestAnalytics(ERPNextTestSuite):
|
||||
def test_sales_analytics(self):
|
||||
frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'")
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import frappe
|
||||
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
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
from erpnext.selling.report.sales_order_analysis.sales_order_analysis import execute
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesOrderAnalysis(IntegrationTestCase):
|
||||
class TestSalesOrderAnalysis(ERPNextTestSuite):
|
||||
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(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import flt, nowdate
|
||||
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||
@@ -11,9 +10,10 @@ from erpnext.selling.report.sales_person_target_variance_based_on_item_group.tes
|
||||
create_sales_target_doc,
|
||||
create_target_distribution,
|
||||
)
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesPartnerTargetVarianceBasedOnItemGroup(IntegrationTestCase):
|
||||
class TestSalesPartnerTargetVarianceBasedOnItemGroup(ERPNextTestSuite):
|
||||
def setUp(self):
|
||||
self.fiscal_year = get_fiscal_year(nowdate())[0]
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import flt, nowdate
|
||||
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
@@ -7,9 +6,10 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde
|
||||
from erpnext.selling.report.sales_person_target_variance_based_on_item_group.sales_person_target_variance_based_on_item_group import (
|
||||
execute,
|
||||
)
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesPersonTargetVarianceBasedOnItemGroup(IntegrationTestCase):
|
||||
class TestSalesPersonTargetVarianceBasedOnItemGroup(ERPNextTestSuite):
|
||||
def setUp(self):
|
||||
self.fiscal_year = get_fiscal_year(nowdate())[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user