summaryrefslogtreecommitdiff
path: root/addons/project_issue
diff options
context:
space:
mode:
authorvbh-odoo <vbh@odoo.com>2015-08-06 16:29:42 +0530
committerDavid Monjoie <dmo@odoo.com>2016-06-30 14:41:25 +0200
commit42b498dc6f6bfd1d375c854d8b415295fbc84e65 (patch)
treef5593b4a11e0a9d8eb75d2488d638b3b811e84c9 /addons/project_issue
parentccfea6b2f614e55c14d8dd3c2ade78d5b91906ec (diff)
[MIG] project_issue: converted test cases from yml to python
Diffstat (limited to 'addons/project_issue')
-rw-r--r--addons/project_issue/__openerp__.py6
-rw-r--r--addons/project_issue/test/issue_demo.yml14
-rw-r--r--addons/project_issue/test/issue_process.yml12
-rw-r--r--addons/project_issue/test/issue_users.yml28
-rw-r--r--addons/project_issue/test/subscribe_issue.yml16
-rw-r--r--addons/project_issue/tests/__init__.py6
-rw-r--r--addons/project_issue/tests/common.py21
-rw-r--r--addons/project_issue/tests/issue.eml (renamed from addons/project_issue/test/issue.eml)0
-rw-r--r--addons/project_issue/tests/test_issue_demo.py18
-rw-r--r--addons/project_issue/tests/test_issue_process.py37
-rw-r--r--addons/project_issue/tests/test_subscribe_issue.py19
11 files changed, 101 insertions, 76 deletions
diff --git a/addons/project_issue/__openerp__.py b/addons/project_issue/__openerp__.py
index d003b39a9dd..7c62d6b7d4c 100644
--- a/addons/project_issue/__openerp__.py
+++ b/addons/project_issue/__openerp__.py
@@ -32,11 +32,5 @@ It allows the manager to quickly check the issues, assign them and decide on the
'views/project_dashboard.xml',
],
'demo': ['data/project_issue_demo.xml'],
- 'test': [
- 'test/issue_users.yml',
- 'test/subscribe_issue.yml',
- 'test/issue_process.yml',
- 'test/issue_demo.yml'
- ],
'application': True,
}
diff --git a/addons/project_issue/test/issue_demo.yml b/addons/project_issue/test/issue_demo.yml
deleted file mode 100644
index f84c716baeb..00000000000
--- a/addons/project_issue/test/issue_demo.yml
+++ /dev/null
@@ -1,14 +0,0 @@
--
- Test the whole create project issue with project manager.
--
- !context
- uid: 'res_users_project_issue_manager'
--
- !record {model: project.issue, id: project_task_1, view: False}:
- task_id: 'project.project_task_17'
- name: 'Error in account module'
--
- !record {model: project.issue, id: project01, view: False}:
- project_id: 'project.project_project_2'
- name: 'OpenERP Integration'
-
diff --git a/addons/project_issue/test/issue_process.yml b/addons/project_issue/test/issue_process.yml
deleted file mode 100644
index 1bc1633688c..00000000000
--- a/addons/project_issue/test/issue_process.yml
+++ /dev/null
@@ -1,12 +0,0 @@
--
- I send mail to get more details. TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
--
- !python {model: mail.mail }: |
- ctx = context.copy()
- ctx.update({'active_model': 'project.issue', 'active_id': ref("crm_case_buginaccountsmodule0"), 'active_ids': [ref("crm_case_buginaccountsmodule0")]})
- vals = self.default_get(cr, uid , [], context=ctx)
- try:
- new_id = self.create(cr, uid, {'email_from': 'support@mycompany.com','email_to': 'Robert_Adersen@yahoo.com', 'subject': 'Regarding error in account module we nees more details'})
- self.send_mail(cr, uid, [new_id], context=ctx)
- except Exception, e:
- pass
diff --git a/addons/project_issue/test/issue_users.yml b/addons/project_issue/test/issue_users.yml
deleted file mode 100644
index a0ad327b86b..00000000000
--- a/addons/project_issue/test/issue_users.yml
+++ /dev/null
@@ -1,28 +0,0 @@
--
- Create a user as 'Project manager'
--
- !record {model: res.users, id: res_users_project_issue_manager, view: False}:
- company_id: base.main_company
- name: Project Manager
- login: prim
- email: issuemanager@yourcompany.com
--
- I added groups for Project manager.
--
- !record {model: res.users, id: res_users_project_issue_manager}:
- groups_id:
- - project.group_project_manager
--
- Create a user as 'Project user'
--
- !record {model: res.users, id: res_users_project_issue_user, view: False}:
- company_id: base.main_company
- name: Project User
- login: priu
- email: issueuser@yourcompany.com
--
- I added groups for Project user.
--
- !record {model: res.users, id: res_users_project_issue_user}:
- groups_id:
- - project.group_project_user
diff --git a/addons/project_issue/test/subscribe_issue.yml b/addons/project_issue/test/subscribe_issue.yml
deleted file mode 100644
index a3645feb156..00000000000
--- a/addons/project_issue/test/subscribe_issue.yml
+++ /dev/null
@@ -1,16 +0,0 @@
--
- In Order to test process of Issue in OpenERP, Customer send the issue by email.
--
- !python {model: mail.thread}: |
- request_file = open(openerp.modules.module.get_module_resource('project_issue','test', 'issue.eml'),'rb')
- request_message = request_file.read()
- self.message_process(cr, uid, 'project.issue', request_message)
--
- After getting the mail, I check details of new issue of that customer.
--
- !python {model: project.issue}: |
- issue_ids = self.search(cr, uid, [('email_from', '=', 'Robert Adersen <Robert_Adersen@yahoo.com>')])
- assert issue_ids and len(issue_ids), "issue is not created after getting request"
- issue = self.browse(cr, uid, issue_ids[0], context=context)
- assert not issue.partner_id, "Customer should be a new"
- assert issue.name == "Error in the account module", "Subject does not match"
diff --git a/addons/project_issue/tests/__init__.py b/addons/project_issue/tests/__init__.py
new file mode 100644
index 00000000000..423b64bf971
--- /dev/null
+++ b/addons/project_issue/tests/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import test_subscribe_issue
+import test_issue_process
+import test_issue_demo
diff --git a/addons/project_issue/tests/common.py b/addons/project_issue/tests/common.py
new file mode 100644
index 00000000000..c5a1654188f
--- /dev/null
+++ b/addons/project_issue/tests/common.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+from odoo.tests.common import TransactionCase
+
+
+class TestIssueUsers(TransactionCase):
+ """Tests for unit of res users"""
+
+ def setUp(self):
+ super(TestIssueUsers, self).setUp()
+ self.ProjectIssue = self.env["project.issue"]
+
+ # Created a user as 'Project Manager'
+ # Added group for Project Manager.
+ self.project_manager = self.env["res.users"].create({
+ 'name': 'Project Manager',
+ 'login': 'prim',
+ 'password': 'prim',
+ 'email': 'issuemanager@yourcompany.com',
+ 'groups_id': [(6, 0, [self.ref('project.group_project_manager')])]
+ })
diff --git a/addons/project_issue/test/issue.eml b/addons/project_issue/tests/issue.eml
index 32659bbd7da..32659bbd7da 100644
--- a/addons/project_issue/test/issue.eml
+++ b/addons/project_issue/tests/issue.eml
diff --git a/addons/project_issue/tests/test_issue_demo.py b/addons/project_issue/tests/test_issue_demo.py
new file mode 100644
index 00000000000..21846a17351
--- /dev/null
+++ b/addons/project_issue/tests/test_issue_demo.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+from odoo.addons.project_issue.tests.common import TestIssueUsers
+
+
+class TestIssueDemo(TestIssueUsers):
+
+ def test_issue_demo(self):
+ # Test the whole create project issue with project manager.
+ self.ProjectIssue.sudo(self.project_manager.id).create({
+ 'name': 'Error in account module',
+ 'task_id': self.ref('project.project_task_17')
+ })
+
+ self.ProjectIssue.sudo(self.project_manager.id).create({
+ 'name': 'Odoo Integration',
+ 'project_id': self.ref('project.project_project_2')
+ })
diff --git a/addons/project_issue/tests/test_issue_process.py b/addons/project_issue/tests/test_issue_process.py
new file mode 100644
index 00000000000..eeedfba39a4
--- /dev/null
+++ b/addons/project_issue/tests/test_issue_process.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+from odoo.addons.project_issue.tests.common import TestIssueUsers
+
+
+class TestIssueProcess(TestIssueUsers):
+
+ def test_issue_process(self):
+ # Sending mail to get more details.
+
+ vals = {'email_from': 'support@mycompany.com',
+ 'email_to': 'Robert_Adersen@yahoo.com',
+ 'subject': 'We need more details regarding your issue in HR module',
+ 'body_html': """
+ <p>
+ Hello Mr. Adersen,
+ </p>
+ <p>
+ We need more details about your issue in the HR module. Could you please
+ send us complete details about the error eg. error message, traceback
+ or what operations you were doing when you the error occured ?
+ </p>
+ <p>
+ Thank You.
+ </p>
+ <pre>
+--
+YourCompany
+info@yourcompany.example.com
++1 555 123 8069
+ </pre>
+ """}
+ crm_bug_id = self.ref('project_issue.crm_case_buginaccountsmodule0')
+ mail = self.env["mail.mail"].with_context(active_model='project.issue',
+ active_id=crm_bug_id,
+ active_ids=[crm_bug_id]).create(vals)
+ mail.send()
diff --git a/addons/project_issue/tests/test_subscribe_issue.py b/addons/project_issue/tests/test_subscribe_issue.py
new file mode 100644
index 00000000000..2577033bbf0
--- /dev/null
+++ b/addons/project_issue/tests/test_subscribe_issue.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+from odoo.addons.project_issue.tests.common import TestIssueUsers
+from odoo.modules import module
+
+
+class TestSubscribeIssue(TestIssueUsers):
+
+ def test_subscribe_issues(self):
+ # In Order to test process of Issue in Odoo, Customer send the issue by email.
+ request_file = open(module.get_module_resource('project_issue', 'tests', 'issue.eml'), 'rb')
+ request_message = request_file.read()
+ self.env["mail.thread"].message_process('project.issue', request_message)
+
+ # After getting the mail, Check details of new issue of that customer.
+ issue = self.ProjectIssue.search([('email_from', '=', 'Robert Adersen <Robert_Adersen@yahoo.com>')], limit=1)
+ self.assertEquals(len(issue), 1, "Issue is not created after getting request")
+ self.assertFalse(issue.partner_id, "Customer should be a new")
+ self.assertEquals(issue.name, "Error in the account module", "Subject does not match")