mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-23 05:42:13 -06:00
[MIG] document_page: Migration to 9.0
This commit is contained in:
5
document_page/tests/__init__.py
Normal file
5
document_page/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_document_page, test_document_page_history
|
||||
from . import test_document_page_create_menu
|
||||
from . import test_document_page_show_diff
|
||||
37
document_page/tests/test_document_page.py
Normal file
37
document_page/tests/test_document_page.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
|
||||
class TestDocumentPage(common.TransactionCase):
|
||||
"""document_page test class."""
|
||||
|
||||
def test_page_creation(self):
|
||||
"""Test page creation."""
|
||||
parent_page = self.env.ref('document_page.demo_category1')
|
||||
|
||||
self.assertEqual(parent_page.name, 'OpenERP Features')
|
||||
|
||||
record = self.env['document.page'].create({
|
||||
'name': 'Test Page1',
|
||||
'parent_id': parent_page.id,
|
||||
'content': 'Test content'
|
||||
})
|
||||
self.assertEqual(record.name, 'Test Page1')
|
||||
|
||||
def test_category_display_content(self):
|
||||
"""Test category display content."""
|
||||
page = self.env.ref('document_page.demo_category1')
|
||||
self.assertTrue(page.display_content.find('Demo') > 1)
|
||||
|
||||
def test_page_display_content(self):
|
||||
"""Test page display content."""
|
||||
page = self.env.ref('document_page.demo_page1')
|
||||
self.assertTrue(page.display_content.find('Demo') > 1)
|
||||
|
||||
def test_page_do_set_content(self):
|
||||
"""Test page set content."""
|
||||
page = self.env.ref('document_page.demo_page1')
|
||||
page.content = None
|
||||
page.do_set_content()
|
||||
self.assertTrue(page.display_content.find('Summary') == 1)
|
||||
30
document_page/tests/test_document_page_create_menu.py
Normal file
30
document_page/tests/test_document_page_create_menu.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
|
||||
class TestDocumentPageCreateMenu(common.TransactionCase):
|
||||
"""document_page_create_menu test class."""
|
||||
|
||||
def test_page_menu_creation(self):
|
||||
"""Test page menu creation."""
|
||||
menu_parent = self.env.ref('base.menu_base_partner')
|
||||
|
||||
menu_created = self.env['document.page.create.menu'].create(
|
||||
{'menu_name': 'Wiki Test menu', 'menu_parent_id': menu_parent.id}
|
||||
)
|
||||
|
||||
menu = self.env['document.page.create.menu'].search(
|
||||
[('id', '=', menu_created.id)]
|
||||
)
|
||||
menu.with_context(
|
||||
active_id=[self.ref('document_page.demo_page1')]
|
||||
).document_page_menu_create()
|
||||
|
||||
fields_list = ["menu_name", "menu_name"]
|
||||
|
||||
res = menu.with_context(
|
||||
active_id=[self.ref('document_page.demo_page1')]
|
||||
).default_get(fields_list)
|
||||
|
||||
self.assertEqual(res['menu_name'], 'OpenERP 6.1. Functional Demo')
|
||||
21
document_page/tests/test_document_page_history.py
Normal file
21
document_page/tests/test_document_page_history.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
|
||||
class TestDocumentPageHistory(common.TransactionCase):
|
||||
"""document_page_history test class."""
|
||||
|
||||
def test_page_history_demo_page1(self):
|
||||
"""Test page history demo page1."""
|
||||
page = self.env.ref('document_page.demo_page1')
|
||||
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.getDiff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, 'There are no changes in revisions.')
|
||||
|
||||
result = history_document.getDiff(active_ids[0], active_ids[1])
|
||||
self.assertNotEqual(result, 'There are no changes in revisions.')
|
||||
36
document_page/tests/test_document_page_show_diff.py
Normal file
36
document_page/tests/test_document_page_show_diff.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.tests import common
|
||||
from openerp import _
|
||||
|
||||
|
||||
class TestDocumentPageShowDiff(common.TransactionCase):
|
||||
"""document_page_show_diff test class."""
|
||||
|
||||
def test_show_demo_page1_diff(self):
|
||||
"""Show test page history difference."""
|
||||
page = self.env.ref('document_page.demo_page1')
|
||||
|
||||
show_diff_object = self.env['wizard.document.page.history.show_diff']
|
||||
|
||||
history_document = self.env['document.page.history']
|
||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
||||
|
||||
self.assertTrue(
|
||||
show_diff_object.with_context(
|
||||
active_ids=[i.id for i in history_pages]
|
||||
).get_diff()
|
||||
)
|
||||
|
||||
page.write({'content': 'Text content updated'})
|
||||
page.write({'content': 'Text updated'})
|
||||
|
||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
||||
|
||||
with self.assertRaises(Exception) as context:
|
||||
show_diff_object.with_context(
|
||||
active_ids=[i.id for i in history_pages]
|
||||
).get_diff()
|
||||
|
||||
self.assertTrue(_("Select one or maximum two history revisions!")
|
||||
in context.exception)
|
||||
Reference in New Issue
Block a user