[MIG] project_issue: converted test cases from yml to python
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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')])]
|
||||
})
|
||||
@@ -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')
|
||||
})
|
||||
@@ -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()
|
||||
@@ -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")
|
||||
Reference in New Issue
Block a user