knowledge/document_page/tests/test_document_page.py
Iván Todorovich 96256b9872 [IMP][9.0] Change Requests and workflow improvements on documents (#155)
* [IMP] Refactor document_page_approval to always use states, and a few code improvements
* [IMP] Add QWeb report to print document pages
* Categories don't save content
* FIX Last Contributor (uid and date). Use related fields instead of computed where possible.
Fix search views, store some fields to make them searchable, added filters
* Add api.depends on computed diff
2018-04-12 15:27:32 -07:00

41 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
from openerp.tests import common
class TestDocumentPage(common.TransactionCase):
def setUp(self):
super(TestDocumentPage, self).setUp()
self.page_obj = self.env['document.page']
self.history_obj = self.env['document.page.history']
self.category1 = self.env.ref('document_page.demo_category1')
self.page1 = self.env.ref('document_page.demo_page1')
def test_page_creation(self):
page = self.page_obj.create({
'name': 'Test Page 1',
'parent_id': self.category1.id,
'content': 'Test content'
})
self.assertEqual(page.content, 'Test content')
self.assertEqual(len(page.history_ids), 1)
page.content = 'New content for Demo Page'
self.assertEqual(len(page.history_ids), 2)
def test_category_template(self):
page = self.page_obj.create({
'name': 'Test Page 2',
'parent_id': self.category1.id,
})
page._onchange_parent_id()
self.assertEqual(page.content, self.category1.template)
def test_page_history_diff(self):
page = self.page_obj.create({
'name': 'Test Page 3',
'content': 'Test content'
})
page.content = 'New content'
self.assertIsNotNone(page.history_ids[0].diff)