refactor: utility to load JSON records

This commit is contained in:
ruthra kumar
2025-06-21 07:30:19 +05:30
parent 0b14d1fe34
commit 6041574209

View File

@@ -8,6 +8,7 @@ from typing import Any, NewType
import frappe
from frappe import _
from frappe.core.doctype.report.report import get_report_module_dotted_path
from frappe.tests.utils import load_test_records_for
from frappe.utils import now_datetime
ReportFilters = dict[str, Any]
@@ -134,6 +135,16 @@ class ERPNextTestSuite(unittest.TestCase):
cls.make_presets()
cls.make_persistent_master_data()
# initilize global test records attribute
if not hasattr(cls, "globalTestRecords"):
cls.globalTestRecords = {}
@classmethod
def load_test_records(cls, doctype):
if doctype not in cls.globalTestRecords:
records = load_test_records_for(doctype)
cls.globalTestRecords[doctype] = records[doctype]
@classmethod
def make_presets(cls):
from frappe.desk.page.setup_wizard.install_fixtures import update_genders, update_salutations