refactor(test): make timesheet and activity type deterministic

This commit is contained in:
ruthra kumar
2025-11-13 13:55:12 +05:30
parent b64231ce2e
commit 524118e108
3 changed files with 28 additions and 3 deletions

View File

@@ -2616,6 +2616,29 @@ class ERPNextTestSuite(unittest.TestCase):
)
)
@classmethod
def make_activity_type(cls):
records = [
{
"doctype": "Activity Type",
"name": "_Test Activity Type",
"activity_type": "_Test Activity Type",
},
{
"doctype": "Activity Type",
"name": "_Test Activity Type 1",
"activity_type": "_Test Activity Type 1",
},
]
cls.activity_type = []
for x in records:
if not frappe.db.exists("Activity Type", {"activity_type": x.get("activity_type")}):
cls.activity_type.append(frappe.get_doc(x).insert())
else:
cls.activity_type.append(
frappe.get_doc("Activity Type", {"activity_type": x.get("activity_type")})
)
@contextmanager
def set_user(self, user: str):
try: