From fc556602cdde8caf01afdfcc4fa9551626620a99 Mon Sep 17 00:00:00 2001 From: Gervais Naoussi Date: Tue, 8 Dec 2015 13:00:05 +0100 Subject: [PATCH] test writed in python --- document_page/test/document_page_test00.yml | 55 ------------------- document_page/tests/__init__.py | 4 ++ document_page/tests/test_document_page.py | 30 ++++++++++ .../tests/test_document_page_create_menu.py | 20 +++++++ .../tests/test_document_page_history.py | 17 ++++++ 5 files changed, 71 insertions(+), 55 deletions(-) delete mode 100644 document_page/test/document_page_test00.yml create mode 100644 document_page/tests/__init__.py create mode 100644 document_page/tests/test_document_page.py create mode 100644 document_page/tests/test_document_page_create_menu.py create mode 100644 document_page/tests/test_document_page_history.py diff --git a/document_page/test/document_page_test00.yml b/document_page/test/document_page_test00.yml deleted file mode 100644 index bc75c64e..00000000 --- a/document_page/test/document_page_test00.yml +++ /dev/null @@ -1,55 +0,0 @@ -- - In order to test the document_page in OpenERP, I create a new page to category demo_category1 -- - !record {model: document.page, id: test_page0}: - name: Test Page0 - parent_id: demo_category1 - content: 'Test content - - The Open ERP wiki allows you to manage your enterprise contents using wiki - - restructured texts. This module provides a collaborative way to manage internal - - FAQs, quality manuals, technical references, etc.' - -- - I check the category index contains my page. -- - !python {model: document.page}: | - res = self.read(cr, uid, [ref('demo_category1')], ['display_content']) - assert res[0]['display_content'].find('Test Page') > 1 -- - !record {model: document.page, id: test_page0}: - content: 'Test updated content - - The Open ERP wiki allows you to manage your enterprise contents using wiki - - restructured texts. This module provides a collaborative way to manage internal - - FAQs, quality manuals, technical references, etc. - - Wiki text can easily be edited - ' - -- - I check the page history for the current page by clicking on "Page History".After that find difference between history. -- - !python {model: wizard.document.page.history.show_diff, id: False}: | - hist_obj = self.env['document.page.history'] - ids = hist_obj.search([('page_id', '=', ref("test_page0"))]) - self.with_context(active_ids=[i.id for i in ids]).get_diff() - - -- - I click the "create menu" link and i fill the form. -- - !record {model: document.page.create.menu, id: test_create_menu0}: - menu_name: Wiki Test menu - menu_parent_id: base.menu_base_partner -- - I create a Menu by clicking on "create menu" -- - !python {model: document.page.create.menu, id: False}: | - menu = self.search([('id', '=', ref("test_create_menu0"))]) - menu.with_context(active_id=[ref('test_page0')]).document_page_menu_create() - diff --git a/document_page/tests/__init__.py b/document_page/tests/__init__.py new file mode 100644 index 00000000..fe18354d --- /dev/null +++ b/document_page/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import test_document_page, test_document_page_history +from . import test_document_page_create_menu diff --git a/document_page/tests/test_document_page.py b/document_page/tests/test_document_page.py new file mode 100644 index 00000000..6b4938d8 --- /dev/null +++ b/document_page/tests/test_document_page.py @@ -0,0 +1,30 @@ +# -*- 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) diff --git a/document_page/tests/test_document_page_create_menu.py b/document_page/tests/test_document_page_create_menu.py new file mode 100644 index 00000000..ee8e4f7d --- /dev/null +++ b/document_page/tests/test_document_page_create_menu.py @@ -0,0 +1,20 @@ +# -*- 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() diff --git a/document_page/tests/test_document_page_history.py b/document_page/tests/test_document_page_history.py new file mode 100644 index 00000000..a69ad671 --- /dev/null +++ b/document_page/tests/test_document_page_history.py @@ -0,0 +1,17 @@ +# -*- 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)]) + history_document.with_context( + active_ids=[i.id for i in history_pages] + ).get_diff()