From 8390365f461a94c158f8da5d3b1bf0f52d02ab5d Mon Sep 17 00:00:00 2001 From: Gervais Naoussi Date: Tue, 8 Dec 2015 18:40:33 +0100 Subject: [PATCH] test code coverage progress --- document_page/tests/__init__.py | 1 + .../tests/test_document_page_show_diff.py | 36 +++++++++++++++++++ .../wizard/document_page_show_diff.py | 3 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 document_page/tests/test_document_page_show_diff.py diff --git a/document_page/tests/__init__.py b/document_page/tests/__init__.py index fe18354d..4c507a03 100644 --- a/document_page/tests/__init__.py +++ b/document_page/tests/__init__.py @@ -2,3 +2,4 @@ from . import test_document_page, test_document_page_history from . import test_document_page_create_menu +from . import test_document_page_show_diff diff --git a/document_page/tests/test_document_page_show_diff.py b/document_page/tests/test_document_page_show_diff.py new file mode 100644 index 00000000..3911afd7 --- /dev/null +++ b/document_page/tests/test_document_page_show_diff.py @@ -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.assertEqual(len([i.id for i in history_pages]), 2) + + self.assertTrue(show_diff_object.with_context( + active_ids=[i.id for i in history_pages] + ).get_diff()) + + page.content = 'Test content updated' + + history_pages = history_document.search([('page_id', '=', page.id)]) + + self.assertEqual(len([i.id for i in history_pages]), 1) + + with self.assertRaises(Exception) as context: + show_diff_object.with_context( + active_ids=[i.id for i in history_pages] + ).get_diff() + + self.assertTrue(_("You need to select minimum one or maximum two history revisions!") in context.exception) diff --git a/document_page/wizard/document_page_show_diff.py b/document_page/wizard/document_page_show_diff.py index bb3ea244..dd960a63 100644 --- a/document_page/wizard/document_page_show_diff.py +++ b/document_page/wizard/document_page_show_diff.py @@ -48,8 +48,7 @@ class DocumentPageShowDiff(models.TransientModel): diff = history.getDiff(ids[0], nids.id) else: raise exceptions.Warning( - _("You need to select minimum one or maximum " - "two history revisions!") + _("You need to select minimum one or maximum two history revisions!") ) return diff