From 00788554f47c36819d11ad9dae5363993cf41448 Mon Sep 17 00:00:00 2001
From: Gervais Naoussi
Date: Tue, 22 Mar 2016 11:14:00 +0100
Subject: [PATCH 1/3] test bug fixed
---
.../data/email_template.xml | 6 ++--
.../security/document_page_security.xml | 2 +-
.../tests/test_document_page_approval.py | 2 +-
.../test_document_page_history_workflow.py | 35 +++++++++++++------
4 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/document_page_approval/data/email_template.xml b/document_page_approval/data/email_template.xml
index b5fc8ad8..e31c8bcb 100644
--- a/document_page_approval/data/email_template.xml
+++ b/document_page_approval/data/email_template.xml
@@ -5,8 +5,7 @@
-
+
Automated new draft need approval Notification Mail
${object.create_uid.company_id.email or 'noreply@localhost.com'}
New version of "${object.page_id.name}" to approve
@@ -14,7 +13,8 @@
${object.create_uid.partner_id.lang}
-
+ Hello,
The page "${object.page_id.name}" has been modified and need your approval.
diff --git a/document_page_approval/security/document_page_security.xml b/document_page_approval/security/document_page_security.xml
index 0e5bfd66..d41d96f8 100644
--- a/document_page_approval/security/document_page_security.xml
+++ b/document_page_approval/security/document_page_security.xml
@@ -1,7 +1,7 @@
-
+
Document approver
diff --git a/document_page_approval/tests/test_document_page_approval.py b/document_page_approval/tests/test_document_page_approval.py
index 0ac7232d..91f97aed 100644
--- a/document_page_approval/tests/test_document_page_approval.py
+++ b/document_page_approval/tests/test_document_page_approval.py
@@ -22,7 +22,7 @@ class TestDocumentPageApproval(common.TransactionCase):
self.assertIsNotNone(page.display_content, 'Page content')
# Check if approval is required
- self.assertFalse(page.is_approval_required(page))
+ self.assertTrue(page.is_approval_required(page) == category.approval_required)
# Check content of an approval page
page.approval_required = True
diff --git a/document_page_approval/tests/test_document_page_history_workflow.py b/document_page_approval/tests/test_document_page_history_workflow.py
index bca965d3..419f6e69 100644
--- a/document_page_approval/tests/test_document_page_history_workflow.py
+++ b/document_page_approval/tests/test_document_page_history_workflow.py
@@ -12,17 +12,30 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
def test_can_user_approve_this_page(self):
"""Test if a user can approve this page."""
- user = self.env.user
+ group = self.env['res.groups'].search([
+ ('name', '=', 'Document approver')
+ ])
category = self.env.ref('document_page.demo_category1')
category.approval_required = True
- category.approver_uid = user
+ category.approver_uid = group
- pages = self.env['document.page.history'].search([
- ('page_id', '=', category.id)
- ])
- page = pages[0]
+ page = self.env['document.page'].create({
+ 'name': 'Test Page10',
+ 'parent_id': category.id
+ })
- self.assertTrue(page.can_user_approve)
+ # history = self.env['document.page.history']
+ # history_ids = history.search(
+ # [
+ # ('page_id', '=', page.id)
+ # ],
+ # limit=1,
+ # order='create_date DESC'
+ #)
+ #history_ids.signal_workflow('page_approval_draft')
+ #state = history_ids.state == 'draft'
+ # state = history_ids[0].page_id == page.id
+ self.assertTrue(page.is_approval_required(page))
def test_get_approvers_guids(self):
"""Get approver guids."""
@@ -30,7 +43,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
- ])
+ ])
page = pages[0]
approvers_guid = page.get_approvers_guids()
self.assertTrue(len(approvers_guid) > 0)
@@ -41,7 +54,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
- ])
+ ])
page = pages[0]
_logger.info("Email: " + str(page.get_approvers_email))
self.assertIsNotNone(page.get_approvers_email)
@@ -52,7 +65,7 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
category.approval_required = True
pages = self.env['document.page.history'].search([
('page_id', '=', category.id)
- ])
+ ])
page = pages[0]
- _logger.info("Page: "+str(page.get_page_url))
+ _logger.info("Page: " + str(page.get_page_url))
self.assertIsNotNone(page.get_page_url)
From ed644b621dfd1242fe46621347fff8f3a60a1e8c Mon Sep 17 00:00:00 2001
From: Gervais Naoussi
Date: Fri, 25 Mar 2016 23:25:09 +0100
Subject: [PATCH 2/3] test error fixed
---
.../security/ir.model.access.csv | 2 +-
.../test_document_page_history_workflow.py | 27 ++++++++-----------
2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/document_page_approval/security/ir.model.access.csv b/document_page_approval/security/ir.model.access.csv
index e4835836..f8e75f15 100644
--- a/document_page_approval/security/ir.model.access.csv
+++ b/document_page_approval/security/ir.model.access.csv
@@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-document_page_history,document.page.history,model_document_page_history,base.group_document_approver_user,1,1,1,0
\ No newline at end of file
+document_page_history,document.page.history,model_document_page_history,group_document_approver_user,1,1,1,0
diff --git a/document_page_approval/tests/test_document_page_history_workflow.py b/document_page_approval/tests/test_document_page_history_workflow.py
index 419f6e69..3210c926 100644
--- a/document_page_approval/tests/test_document_page_history_workflow.py
+++ b/document_page_approval/tests/test_document_page_history_workflow.py
@@ -12,30 +12,25 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
def test_can_user_approve_this_page(self):
"""Test if a user can approve this page."""
- group = self.env['res.groups'].search([
- ('name', '=', 'Document approver')
- ])
category = self.env.ref('document_page.demo_category1')
category.approval_required = True
- category.approver_uid = group
+ category.approver_gid = self.env.ref('document_page_approval.group_document_approver_user')
page = self.env['document.page'].create({
'name': 'Test Page10',
+ 'content': 'A difficult test',
'parent_id': category.id
})
- # history = self.env['document.page.history']
- # history_ids = history.search(
- # [
- # ('page_id', '=', page.id)
- # ],
- # limit=1,
- # order='create_date DESC'
- #)
- #history_ids.signal_workflow('page_approval_draft')
- #state = history_ids.state == 'draft'
- # state = history_ids[0].page_id == page.id
- self.assertTrue(page.is_approval_required(page))
+ history = self.env['document.page.history'].search(
+ [
+ ('page_id', '=', page.id)
+ ],
+ limit=1,
+ order='create_date DESC'
+ )
+
+ self.assertTrue(history.can_user_approve_page)
def test_get_approvers_guids(self):
"""Get approver guids."""
From 2ed1c6c7ba6fb2a0233775ae9d9fd1387614216b Mon Sep 17 00:00:00 2001
From: Gervais Naoussi
Date: Fri, 25 Mar 2016 23:32:55 +0100
Subject: [PATCH 3/3] Lint error improved
---
.../tests/test_document_page_approval.py | 7 ++++---
.../tests/test_document_page_history_workflow.py | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/document_page_approval/tests/test_document_page_approval.py b/document_page_approval/tests/test_document_page_approval.py
index 91f97aed..4c0e8457 100644
--- a/document_page_approval/tests/test_document_page_approval.py
+++ b/document_page_approval/tests/test_document_page_approval.py
@@ -10,19 +10,20 @@ class TestDocumentPageApproval(common.TransactionCase):
# Check content of a category
category = self.env['document.page'].search([
('name', '=', 'OpenERP Features')
- ])
+ ])
self.assertIsNotNone(category.display_content, 'a category')
# Check content of a page
pages = self.env['document.page'].search([
('parent_id', '=', category.id)
- ])
+ ])
page = pages[0]
self.assertIsNotNone(page.display_content, 'Page content')
# Check if approval is required
- self.assertTrue(page.is_approval_required(page) == category.approval_required)
+ self.assertTrue(page.is_approval_required(page) ==
+ category.approval_required)
# Check content of an approval page
page.approval_required = True
diff --git a/document_page_approval/tests/test_document_page_history_workflow.py b/document_page_approval/tests/test_document_page_history_workflow.py
index 3210c926..508aff80 100644
--- a/document_page_approval/tests/test_document_page_history_workflow.py
+++ b/document_page_approval/tests/test_document_page_history_workflow.py
@@ -14,7 +14,8 @@ class TestDocumentPageHistoryWorkflow(common.TransactionCase):
"""Test if a user can approve this page."""
category = self.env.ref('document_page.demo_category1')
category.approval_required = True
- category.approver_gid = self.env.ref('document_page_approval.group_document_approver_user')
+ category.approver_gid = self.env.ref(
+ 'document_page_approval.group_document_approver_user')
page = self.env['document.page'].create({
'name': 'Test Page10',