mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-27 07:17:43 -06:00
[IMP] document_page: Use html_diff for checking differences
This commit is contained in:
@@ -1,19 +1,48 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.tests import common
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
|
||||
class TestDocumentPageHistory(common.TransactionCase):
|
||||
"""document_page_history test class."""
|
||||
|
||||
def test_page_history_demo_page1(self):
|
||||
def test_old_page_history_demo_page1(self):
|
||||
"""Test page history demo page1."""
|
||||
page = self.env.ref("document_page.demo_page1")
|
||||
page = self.env["document.page"].create(
|
||||
{
|
||||
"name": "Test Page",
|
||||
"content": "Initial content",
|
||||
}
|
||||
)
|
||||
page.content = "Test content updated"
|
||||
history_document = self.env["document.page.history"]
|
||||
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||
active_ids = [i.id for i in history_pages]
|
||||
|
||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, "There are no changes in revisions.")
|
||||
with (
|
||||
patch(
|
||||
"odoo.addons.document_page.models.document_page_history.html_diff", None
|
||||
),
|
||||
mute_logger("odoo.addons.document_page.models.document_page_history"),
|
||||
):
|
||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, "There are no changes in revisions.")
|
||||
|
||||
result = history_document._get_diff(active_ids[0], active_ids[1])
|
||||
self.assertNotEqual(result, "There are no changes in revisions.")
|
||||
result = history_document._get_diff(active_ids[0], active_ids[1])
|
||||
self.assertNotEqual(result, "There are no changes in revisions.")
|
||||
|
||||
def test_new_page_history_demo_page1(self):
|
||||
"""Test page history demo page1."""
|
||||
page = self.env["document.page"].create(
|
||||
{
|
||||
"name": "Test Page",
|
||||
"content": "Initial content",
|
||||
}
|
||||
)
|
||||
page.content = "Test content updated"
|
||||
history_document = self.env["document.page.history"]
|
||||
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||
active_ids = [i.id for i in history_pages]
|
||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, page.content)
|
||||
|
||||
@@ -8,7 +8,12 @@ class TestDocumentPageShowDiff(common.TransactionCase):
|
||||
|
||||
def test_show_demo_page1_diff(self):
|
||||
"""Show test page history difference."""
|
||||
page = self.env.ref("document_page.demo_page1")
|
||||
page = self.env["document.page"].create(
|
||||
{
|
||||
"name": "Test Page",
|
||||
"content": "Initial content",
|
||||
}
|
||||
)
|
||||
|
||||
show_diff_object = self.env["wizard.document.page.history.show_diff"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user