* 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
29 lines
681 B
Python
29 lines
681 B
Python
import frappe
|
|
from frappe.core.doctype.doctype.test_doctype import new_doctype
|
|
from frappe.tests import IntegrationTestCase
|
|
|
|
|
|
class TestRating(IntegrationTestCase):
|
|
def setUp(self):
|
|
doc = new_doctype(
|
|
fields=[
|
|
{
|
|
"fieldname": "rating",
|
|
"fieldtype": "Rating",
|
|
"label": "rating",
|
|
"reqd": 1, # mandatory
|
|
},
|
|
],
|
|
)
|
|
doc.insert()
|
|
self.doctype_name = doc.name
|
|
|
|
def test_negative_rating(self):
|
|
doc = frappe.new_doc(doctype=self.doctype_name, rating=-1)
|
|
doc.insert()
|
|
self.assertEqual(doc.rating, 0)
|
|
|
|
def test_positive_rating(self):
|
|
doc = frappe.new_doc(doctype=self.doctype_name, rating=5)
|
|
doc.insert()
|
|
self.assertEqual(doc.rating, 1)
|