Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: unit test cases boilerplate #43507

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -15,7 +15,7 @@
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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,
Expand All @@ -21,7 +21,16 @@
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions erpnext/accounts/doctype/bisect_nodes/test_bisect_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions erpnext/accounts/doctype/dunning/test_dunning.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,7 +19,16 @@
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@


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
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
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()
Expand All @@ -35,7 +35,7 @@ def set_system_and_company_settings(self):
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},
)
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_01_revaluation_of_forex_balance(self):
)[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},
)
Expand Down Expand Up @@ -158,7 +158,7 @@ def test_02_accounts_only_with_base_currency_balance(self):
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},
)
Expand Down Expand Up @@ -247,7 +247,7 @@ def test_03_accounts_only_with_account_currency_balance(self):
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},
)
Expand Down
19 changes: 14 additions & 5 deletions erpnext/accounts/doctype/journal_entry/test_journal_entry.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -13,8 +11,19 @@
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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,7 +15,16 @@
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"):
Expand Down
21 changes: 15 additions & 6 deletions erpnext/accounts/doctype/payment_entry/test_payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +28,16 @@
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()

Expand Down Expand Up @@ -383,7 +392,7 @@ def test_payment_entry_against_payment_terms_with_discount_amount(self):
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,
Expand Down Expand Up @@ -1090,7 +1099,7 @@ def test_details_update_on_reference_table(self):
}
self.assertDictEqual(ref_details, expected_response)

@change_settings(
@IntegrationTestCase.change_settings(
"Accounts Settings",
{
"unlink_payment_on_cancellation_of_invoice": 1,
Expand Down Expand Up @@ -1185,7 +1194,7 @@ def test_overallocation_validation_on_payment_terms(self):
si3.cancel()
si3.delete()

@change_settings(
@IntegrationTestCase.change_settings(
"Accounts Settings",
{
"unlink_payment_on_cancellation_of_invoice": 1,
Expand Down Expand Up @@ -1791,7 +1800,7 @@ def test_opening_flag_for_advance_as_liability(self):
# '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 (
Expand Down
Loading
Loading