Skip to content

Commit a7dde4f

Browse files
authored
Merge pull request #53701 from frappe/version-16-hotfix
2 parents 8b10311 + d16adb1 commit a7dde4f

439 files changed

Lines changed: 6044 additions & 5446 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run-indinvidual-tests.yml renamed to .github/workflows/run-individual-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
workflow_dispatch:
55

66
concurrency:
7-
group: server-individual-tests-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }}
8-
cancel-in-progress: false
7+
group: server-individual-tests-lightmode-develop
8+
cancel-in-progress: true
99

1010
permissions:
1111
contents: read
@@ -21,7 +21,7 @@ jobs:
2121
- id: set-matrix
2222
run: |
2323
# Use grep and find to get the list of test files
24-
matrix=$(find . -path '*/doctype/*/test_*.py' | xargs grep -l 'def test_' | awk '{
24+
matrix=$(find . -path '*/test_*.py' | xargs grep -l 'def test_' | sort | awk '{
2525
# Remove ./ prefix, file extension, and replace / with .
2626
gsub(/^\.\//, "", $0)
2727
gsub(/\.py$/, "", $0)
@@ -58,6 +58,7 @@ jobs:
5858
strategy:
5959
fail-fast: false
6060
matrix: ${{fromJson(needs.discover.outputs.matrix)}}
61+
max-parallel: 14
6162

6263
name: Test
6364

@@ -130,4 +131,13 @@ jobs:
130131
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
131132

132133
- name: Run Tests
133-
run: 'cd ~/frappe-bench/ && bench --site test_site run-tests --app erpnext --module ${{ matrix.test }}'
134+
run: |
135+
site_name=$(echo "${{matrix.test}}" | sed -e 's/.*\.\(test_.*$\)/\1/')
136+
echo "$site_name"
137+
mkdir ~/frappe-bench/sites/$site_name
138+
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/$site_name/site_config.json
139+
cd ~/frappe-bench/
140+
bench --site $site_name reinstall --yes
141+
bench --site $site_name set-config allow_tests true
142+
bench --site $site_name run-tests --module ${{ matrix.test }} --lightmode
143+

.github/workflows/server-tests-mariadb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
FRAPPE_BRANCH: ${{ github.event.client_payload.sha || github.event.inputs.branch }}
130130

131131
- name: Run Tests
132-
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --total-builds ${{ strategy.job-total }} --build-number ${{ matrix.container }} --with-coverage'
132+
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --lightmode --app erpnext --total-builds ${{ strategy.job-total }} --build-number ${{ matrix.container }} --with-coverage'
133133
env:
134134
TYPE: server
135135

erpnext/accounts/deferred_revenue.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ def make_gl_entries(
524524
if gl_entries:
525525
try:
526526
make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
527-
frappe.db.commit()
527+
if not frappe.in_test:
528+
frappe.db.commit()
528529
except Exception as e:
529530
if frappe.in_test:
530531
doc.log_error(f"Error while processing deferred accounting for Invoice {doc.name}")
@@ -606,7 +607,8 @@ def book_revenue_via_journal_entry(
606607
if submit:
607608
journal_entry.submit()
608609

609-
frappe.db.commit()
610+
if not frappe.in_test:
611+
frappe.db.commit()
610612
except Exception:
611613
frappe.db.rollback()
612614
doc.log_error(f"Error while processing deferred accounting for Invoice {doc.name}")

erpnext/accounts/doctype/account/test_account.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import unittest
44

55
import frappe
6-
from frappe.tests import IntegrationTestCase
76
from frappe.utils import nowdate
87

98
from erpnext.accounts.doctype.account.account import (
@@ -12,11 +11,10 @@
1211
update_account_number,
1312
)
1413
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
14+
from erpnext.tests.utils import ERPNextTestSuite
1515

16-
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company"]
1716

18-
19-
class TestAccount(IntegrationTestCase):
17+
class TestAccount(ERPNextTestSuite):
2018
def test_rename_account(self):
2119
if not frappe.db.exists("Account", "1210 - Debtors - _TC"):
2220
acc = frappe.new_doc("Account")

erpnext/accounts/doctype/account/test_records.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

erpnext/accounts/doctype/account_category/test_account_category.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,3 @@
22
# See license.txt
33

44
# import frappe
5-
from frappe.tests import IntegrationTestCase
6-
7-
# On IntegrationTestCase, the doctype test records and all
8-
# link-field test record dependencies are recursively loaded
9-
# Use these module variables to add/remove to/from that list
10-
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
11-
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
12-
13-
14-
class IntegrationTestAccountCategory(IntegrationTestCase):
15-
"""
16-
Integration tests for AccountCategory.
17-
Use this class for testing interactions between multiple components.
18-
"""
19-
20-
pass

erpnext/accounts/doctype/account_closing_balance/test_account_closing_balance.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# See license.txt
33

44
# import frappe
5-
from frappe.tests import IntegrationTestCase
65

6+
from erpnext.tests.utils import ERPNextTestSuite
77

8-
class TestAccountClosingBalance(IntegrationTestCase):
8+
9+
class TestAccountClosingBalance(ERPNextTestSuite):
910
pass

erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def set_fieldname_and_label(self):
103103
if not self.fieldname:
104104
self.fieldname = scrub(self.label)
105105

106-
def on_update(self):
107-
frappe.flags.accounting_dimensions = None
108-
frappe.flags.accounting_dimensions_details = None
109-
110106

111107
def make_dimension_in_accounting_doctypes(doc, doclist=None):
112108
if not doclist:
@@ -241,34 +237,26 @@ def get_doctypes_with_dimensions():
241237
return frappe.get_hooks("accounting_dimension_doctypes")
242238

243239

244-
def get_accounting_dimensions(as_list=True, filters=None):
245-
if not filters:
246-
filters = {"disabled": 0}
247-
248-
if frappe.flags.accounting_dimensions is None:
249-
frappe.flags.accounting_dimensions = frappe.get_all(
250-
"Accounting Dimension",
251-
fields=["label", "fieldname", "disabled", "document_type"],
252-
filters=filters,
253-
)
240+
def get_accounting_dimensions(as_list=True):
241+
accounting_dimensions = frappe.get_all(
242+
"Accounting Dimension",
243+
fields=["label", "fieldname", "disabled", "document_type"],
244+
filters={"disabled": 0},
245+
)
254246

255247
if as_list:
256-
return [d.fieldname for d in frappe.flags.accounting_dimensions]
248+
return [d.fieldname for d in accounting_dimensions]
257249
else:
258-
return frappe.flags.accounting_dimensions
250+
return accounting_dimensions
259251

260252

261253
def get_checks_for_pl_and_bs_accounts():
262-
if frappe.flags.accounting_dimensions_details is None:
263-
# nosemgrep
264-
frappe.flags.accounting_dimensions_details = frappe.db.sql(
265-
"""SELECT p.label, p.disabled, p.fieldname, c.default_dimension, c.company, c.mandatory_for_pl, c.mandatory_for_bs
254+
return frappe.db.sql(
255+
"""SELECT p.label, p.disabled, p.fieldname, c.default_dimension, c.company, c.mandatory_for_pl, c.mandatory_for_bs
266256
FROM `tabAccounting Dimension`p ,`tabAccounting Dimension Detail` c
267257
WHERE p.name = c.parent AND p.disabled = 0""",
268-
as_dict=1,
269-
)
270-
271-
return frappe.flags.accounting_dimensions_details
258+
as_dict=1,
259+
)
272260

273261

274262
def get_dimension_with_children(doctype, dimensions):

erpnext/accounts/doctype/accounting_dimension/test_accounting_dimension.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import unittest
44

55
import frappe
6-
from frappe.tests import IntegrationTestCase
76

87
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
98
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
9+
from erpnext.tests.utils import ERPNextTestSuite
1010

11-
EXTRA_TEST_RECORD_DEPENDENCIES = ["Cost Center", "Location", "Warehouse", "Department"]
1211

13-
14-
class TestAccountingDimension(IntegrationTestCase):
12+
class TestAccountingDimension(ERPNextTestSuite):
1513
def setUp(self):
1614
create_dimension()
1715

@@ -80,11 +78,6 @@ def test_mandatory(self):
8078
si.save()
8179
self.assertRaises(frappe.ValidationError, si.submit)
8280

83-
def tearDown(self):
84-
disable_dimension()
85-
frappe.flags.accounting_dimensions_details = None
86-
frappe.flags.dimension_filter_map = None
87-
8881

8982
def create_dimension():
9083
frappe.set_user("Administrator")

erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,34 @@ def validate_applicable_accounts(self):
6969

7070

7171
def get_dimension_filter_map():
72-
if not frappe.flags.get("dimension_filter_map"):
73-
filters = frappe.db.sql(
74-
"""
75-
SELECT
76-
a.applicable_on_account, d.dimension_value, p.accounting_dimension,
77-
p.allow_or_restrict, p.fieldname, a.is_mandatory
78-
FROM
79-
`tabApplicable On Account` a,
80-
`tabAccounting Dimension Filter` p
81-
LEFT JOIN `tabAllowed Dimension` d ON d.parent = p.name
82-
WHERE
83-
p.name = a.parent
84-
AND p.disabled = 0
85-
""",
86-
as_dict=1,
87-
)
88-
89-
dimension_filter_map = {}
72+
filters = frappe.db.sql(
73+
"""
74+
SELECT
75+
a.applicable_on_account, d.dimension_value, p.accounting_dimension,
76+
p.allow_or_restrict, p.fieldname, a.is_mandatory
77+
FROM
78+
`tabApplicable On Account` a,
79+
`tabAccounting Dimension Filter` p
80+
LEFT JOIN `tabAllowed Dimension` d ON d.parent = p.name
81+
WHERE
82+
p.name = a.parent
83+
AND p.disabled = 0
84+
""",
85+
as_dict=1,
86+
)
9087

91-
for f in filters:
92-
build_map(
93-
dimension_filter_map,
94-
f.fieldname,
95-
f.applicable_on_account,
96-
f.dimension_value,
97-
f.allow_or_restrict,
98-
f.is_mandatory,
99-
)
100-
frappe.flags.dimension_filter_map = dimension_filter_map
88+
dimension_filter_map = {}
10189

102-
return frappe.flags.dimension_filter_map
90+
for f in filters:
91+
build_map(
92+
dimension_filter_map,
93+
f.fieldname,
94+
f.applicable_on_account,
95+
f.dimension_value,
96+
f.allow_or_restrict,
97+
f.is_mandatory,
98+
)
99+
return dimension_filter_map
103100

104101

105102
def build_map(map_object, dimension, account, filter_value, allow_or_restrict, is_mandatory):

0 commit comments

Comments
 (0)