seitime-frappe/frappe/tests/test_deferred_insert.py
David Arnold c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00

18 lines
713 B
Python

import frappe
from frappe.deferred_insert import deferred_insert, save_to_db
from frappe.tests import IntegrationTestCase
class TestDeferredInsert(IntegrationTestCase):
def test_deferred_insert(self):
route_history = {"route": frappe.generate_hash(), "user": "Administrator"}
deferred_insert("Route History", [route_history])
save_to_db()
self.assertTrue(frappe.db.exists("Route History", route_history))
route_history = {"route": frappe.generate_hash(), "user": "Administrator"}
deferred_insert("Route History", [route_history])
frappe.clear_cache() # deferred_insert cache keys are supposed to be persistent
save_to_db()
self.assertTrue(frappe.db.exists("Route History", route_history))