[MIG] document_page_reference: Migration to 18.0

[FIX]document_page_reference :log warning updated

[FIX]document_page_reference: null value issue fixed
This commit is contained in:
Anusha
2025-06-13 18:13:44 +02:00
parent f60acf8308
commit 7307e198ba
7 changed files with 120 additions and 179 deletions

View File

@@ -18,61 +18,48 @@ class TestDocumentReference(TransactionCase):
{"name": "Test Page 1", "content": "${r1}", "reference": "r2"}
)
def test_constrains_01(self):
def test_constraints_duplicate_reference(self):
"""Should raise if reference is not unique (same as another)."""
with self.assertRaises(ValidationError):
self.page2.write({"reference": self.page1.reference})
def test_constrains_02(self):
def test_constraints_invalid_reference(self):
"""Should raise if reference does not match the required pattern."""
with self.assertRaises(ValidationError):
self.page2.write({"reference": self.page2.reference + "-02"})
def test_no_contrains(self):
self.page1.write({"reference": False})
self.page2.write({"reference": False})
self.assertEqual(self.page1.reference, self.page2.reference)
def test_check_raw(self):
self.assertEqual(self.page2.display_name, self.page1.get_raw_content())
def test_check_reference(self):
self.assertRegex(self.page1.content_parsed, ".*%s.*" % self.page2.display_name)
def test_no_reference(self):
self.page2.reference = "r3"
self.assertRegex(self.page1.content_parsed, ".*r2.*")
def test_auto_reference(self):
"""Test if reference is proposed when saving a page without one."""
self.assertEqual(self.page1.reference, "R1")
new_page = self.page_obj.create(
{"name": "Test Page with no rEfErenCe", "content": "some content"}
{"name": "Test Page with no reference", "content": "some content"}
)
self.assertEqual(new_page.reference, "test_page_with_no_reference")
new_page_duplicated_name = self.page_obj.create(
{
"name": "test page with no reference",
"content": "this should have an empty reference "
"because reference must be unique",
}
)
self.assertFalse(new_page_duplicated_name.reference)
with self.assertRaises(ValidationError):
new_page_duplicated_name = self.page_obj.create(
{
"name": "test page with no reference",
"content": "this should have an empty reference "
"because reference must be unique",
}
)
self.assertFalse(new_page_duplicated_name.reference)
def test_get_formview_action(self):
res = self.page1.get_formview_action()
view_id = self.env.ref("document_page.view_wiki_form").id
expected_result = {
expected_keys = {
"type": "ir.actions.act_window",
"context": {},
"res_model": "document.page",
"res_id": self.page1.id,
"view_mode": "form",
"view_type": "form",
"context": {},
"target": "current",
"views": [(view_id, "form")],
}
self.assertEqual(res, expected_result)
for key, expected_value in expected_keys.items():
self.assertEqual(res.get(key), expected_value, f"Mismatch in key: {key}")
def test_compute_content_parsed(self):
self.page1.content = "<p>"
self.page1.content = "<p></p>"
self.page1._compute_content_parsed()
self.assertEqual(str(self.page1.content_parsed), "<p></p>")