From 0710d3b8d4b511df2cae2758c64e9cbb0301b97e Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 25 Aug 2011 11:14:58 +0530 Subject: [PATCH] [IMP]project : Improve the test cases bzr revid: dbr@tinyerp.com-20110825054458-48t8ynjmom1b7u74 --- addons/project/test/test_project.yml | 133 +++++++++++- .../project/test/test_project_delegation.yml | 195 +++++++++--------- 2 files changed, 231 insertions(+), 97 deletions(-) diff --git a/addons/project/test/test_project.yml b/addons/project/test/test_project.yml index f79c2a34224..43ad07abe05 100644 --- a/addons/project/test/test_project.yml +++ b/addons/project/test/test_project.yml @@ -1,5 +1,10 @@ - - Test project template feature + I assign an email address to Administrator. +- + !record {model: res.users, id: base.user_root}: + user_email: admin@openerp.com +- + Now, Test project template feature - Create project 'OpenERP Training Programme' - @@ -12,6 +17,7 @@ !record {model: project.task, id: project_task_technicaltraining0}: date_start: !eval time.strftime('%Y-%m-%d %H:%M:%S') name: Technical Training + user_id: base.user_root planned_hours: 30.0 project_id: project_project_openerptrainingprogramme0 remaining_hours: 30.0 @@ -26,6 +32,58 @@ project_id: project_project_openerptrainingprogramme0 remaining_hours: 30.0 state: draft +- + Set project's task view +- + !python {model: project.task}: | + self._default_project(cr, uid,context) + self.fields_view_get(cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False) +- + Check child project. +- + !python {model: project.task}: | + self._check_child_task(cr, uid, [ref("project_task_functionaltraining0")]) +- + Do some changes on project. +- + !python {model: project.task}: | + self.onchange_project(cr, uid, [ref("project_task_functionaltraining0")],ref('project_project_openerptrainingprogramme0')) +- + Change the type of project. +- + !python {model: project.task}: | + self._change_type(cr, uid,[ref("project_task_functionaltraining0")], next, context) +- + Click on next Button. +- + !python {model: project.task}: | + self.next_type(cr, uid,[ref("project_task_functionaltraining0")], context) +- + Click on previous Button. +- + !python {model: project.task}: | + self.prev_type(cr, uid,[ref("project_task_functionaltraining0")], context) +- + Create work for project's task. +- + !record {model: project.task.work, id: project_task_work0}: + name: Technical Training Task's Work + task_id: project_task_technicaltraining0 +- + Add project's Work +- + !python {model: project.task.work}: | + self.write(cr, uid, [ref('project_task_work0')], vals={}, context={"lang": "en_US", "active_ids": [ref("project_task_functionaltraining0")],"tz": False, "active_id": ref("project_task_functionaltraining0")}) +- + Get project's Work +- + !python {model: project.project}: | + self._get_project_work(cr, uid, [ref("project_task_work0")], context={"lang": "en_US", "active_ids": [ref("project_task_functionaltraining0")],"tz": False, "active_id": ref("project_task_functionaltraining0")}) +- + Change the project's partner if needed. +- + !python {model: project.project}: | + self.onchange_partner_id(cr, uid, [ref("project_project_openerptrainingprogramme0")], part=False, context = {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_open_view_project_all")],"tz": False, "active_id": ref("project.menu_open_view_project_all")}) - Set project as project template - @@ -101,7 +159,7 @@ "tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"), }) - - Check if project in open state + Re-Check if project in open state - !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in open state}: - state == "open" @@ -118,7 +176,17 @@ !record {model: project.task.reevaluate, id: project_task_technicaltraining_remainingwiz0}: remaining_hours: 30.0 - | - I click the apply button + Create the view for reevaluate the task. +- + !python {model: project.task.reevaluate}: | + self.fields_view_get(cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False) +- | + Now get the remaining hours required to close the task. +- + !python {model: project.task.reevaluate}: | + self._get_remaining(cr, uid) +- | + I click the apply button. - !python {model: project.task.reevaluate}: | self.compute_hours(cr, uid, [ref('project_task_technicaltraining_remainingwiz0')], {'active_id': ref("project_task_technicaltraining0"),'button_reactivate': True}) @@ -176,6 +244,11 @@ !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After one more work task of 10 hours effective_hours must be equal to 30}: - remaining_hours == 0 - effective_hours == 30.0 +- + Create analytic account. +- + !record {model: account.analytic.account, id: account_analytic_account0}: + name : account_analytic_account - Set remaining hours of 10 hours for reevaluating the task - @@ -223,8 +296,6 @@ - !assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Task is in done state}: - state == "done" - - - Test for task reactivation - @@ -264,6 +335,11 @@ - planned_hours == 30 - remaining_hours == 5.0 - effective_hours == 45.0 +- + Check for remaining hours +- + !python {model: project.task}: | + self.onchange_remaining(cr, uid, [ref("project_task_functionaltraining0")], remaining = 0.0, planned = 0.0) - Close the task - @@ -293,4 +369,51 @@ - !assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: "Project must be in closed state"}: - state == "close" +- + Unlink the task's work. +- + !python {model: project.task.work}: | + self.unlink(cr, uid, [ref('project_task_work0')]) +- + After remove project task's work unlink it's details from the analytic account. +- + !python {model: account.analytic.account}: | + self.unlink(cr, uid, [ref('account_analytic_account0')]) +- + Now, Close the project task +- + !record {model: project.task.close, id: project_task_close_0}: + manager_warn : True + partner_warn : False + manager_email : 'info@mycustomer.com' + partner_email : 'info@myinfobid.com' + description : Description +- + Send Warn Message by Email to Manager and Customer. +- + !python {model: project.task.close}: | + fields = { + 'manager_warn' : True, + 'partner_warn' : False, + 'manager_email' : 'info@mycustomer.com', + 'partner_email' : 'info@myinfobid.com', + 'description' : 'Description' + } + self.default_get(cr, uid, fields, context={"active_ids":[ref("project_task_technicaltraining0")],"active_id": ref("project_task_technicaltraining0")}) + self.send(cr, uid, [ref('project_task_close_0')], context={"active_ids":[ref("project_task_technicaltraining0")],"active_id": ref("project_task_technicaltraining0")}) +- + Close this project. +- + !python {model: project.task}: | + self.action_close(cr, uid, [ref("project_task_functionaltraining0")],context={"lang": "en_US", "active_ids": [ref("project_project_openerptrainingprogramme0")],"tz": False, "active_id": ref("project_project_openerptrainingprogramme0")}) +- + Cancel this project. +- + !python {model: project.task}: | + self.do_cancel(cr, uid,[ref("project_task_functionaltraining0")],context={}) +- + Unlink this project. +- + !python {model: project.task}: | + self.unlink(cr, uid,[ref("project_task_functionaltraining0")]) diff --git a/addons/project/test/test_project_delegation.yml b/addons/project/test/test_project_delegation.yml index 02bc9afaae8..730c019b701 100644 --- a/addons/project/test/test_project_delegation.yml +++ b/addons/project/test/test_project_delegation.yml @@ -1,115 +1,125 @@ - - This scenario tests the delegation process. Closing all the delegated tasks(task delegation at multiple levels) transits the parent task from pending to open state. -- + This scenario tests the delegation process. Closing all the delegated tasks(task delegation at multiple levels) transits the parent task from pending to open state. +- Creating a project OpenERP Documentation -- +- !record {model: project.project, id: project_project_openerpdocumentation0}: company_id: base.main_company - name: OpenERP Documentation - -- + name: OpenERP Documentation + +- Creating a task 'Develop book for Technical and Functional reference' -- +- !record {model: project.task, id: project_task_documentation_book}: name: Develop book for Technical and Functional reference planned_hours: 20.0 project_id: project_project_openerpdocumentation0 remaining_hours: 20.0 state: draft - -- - Open the task -- +- + Open the 'Develop book for Technical and Functional reference' task +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_documentation_book")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], - "tz": False, "active_id": ref("project.menu_action_view_task"), }) + "tz": False, "active_id": ref("project.menu_action_view_task"), }) -- +- Creating a task 'Publish the References' -- +- !record {model: project.task, id: project_task_publish_book}: name: Publish the References planned_hours: 10.0 project_id: project_project_openerpdocumentation0 remaining_hours: 10.0 state: draft - -- - Open the task -- + +- + Open the task 'Publish the References' +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_publish_book")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], - "tz": False, "active_id": ref("project.menu_action_view_task"), }) + "tz": False, "active_id": ref("project.menu_action_view_task"), }) - - Test the delegate wizard -- + Test the delegate wizard +- Creating a delegate task 'Publish the References' of 15 hours, renaming parent task to 'CHECK Publish the References' of 1 hour -- +- !record {model: project.task.delegate, id: project_task_publish_book_delegate}: name: Publish the References - new_task_description: aaa + new_task_description: test_new_task planned_hours: 15.0 planned_hours_me: 1.0 prefix: 'CHECK: Publish the References' state: pending user_id: base.user_demo - -- - Validating the delegate task -- +- + Create view for delegate task. +- !python {model: project.task.delegate}: | - self.delegate(cr, uid, [ref("project_task_publish_book_delegate")], - {"lang": "en_US", "active_model": "project.task", "tz": False, "record_id": - 4, "active_ids": [ref("project_task_publish_book")], "active_id": ref("project_task_publish_book"), - }) - + fields = { + 'name' : 'Test', + 'new_task_description' : 'test_new_task', + 'planned_hours' : '15.0', + 'planned_hours_me' : '1.0', + 'prefix' : 'CHECK_Publish the References', + 'state' : 'pending', + 'user_id' : 'base.user_root' + } + context = {"lang": "en_US", "active_model": "project.task", "tz": False,"record_id":4, "active_ids": [ref("project_task_publish_book")], "active_id": ref("project_task_publish_book")} + self.default_get(cr, uid, fields, context=context) + self.fields_view_get(cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False) +- + Validating the delegate task. +- + !python {model: project.task.delegate}: | + self.delegate(cr, uid, [ref("project_task_publish_book_delegate")],context={"lang": "en_US", "active_model": "project.task", "tz": False,"record_id":4, "active_ids": [ref("project_task_publish_book")], "active_id": ref("project_task_publish_book")}) - Check if parent task 'CHECK Publish the References' is in pending state -- +- !assert {model: project.task, id: project_task_publish_book, severity: error, string: "Task must be in pending state after delegation"}: - - state == "pending" -- - Creating a delegate task 'Prepare a book that gives functional overview of OpenERP' -- + - state == "pending" +- + Creating a delegate task 'Prepare a book that gives functional overview of OpenERP' +- !record {model: project.task, id: project_task_delegate_openerp_tutorial}: name: Prepare a book that gives functional overview of OpenERP planned_hours: 30.0 project_id: project.project_project_openerpdocumentation0 remaining_hours: 30.0 state: draft - -- - Open the task -- + +- + Open the delegate task 'Prepare a book that gives functional overview of OpenERP' +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_delegate_openerp_tutorial")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_id": ref("project.menu_action_view_task"), }) - -- + +- Creating a delegate task 'Prepare a technical reference for creating your modules' -- +- !record {model: project.task, id: project_task_delegate_developer_book}: name: Prepare a technical reference for creating your modules planned_hours: 30.0 project_id: project_project_openerpdocumentation0 remaining_hours: 30.0 state: draft - -- - Open the task -- + +- + Open the delegate task 'Prepare a technical reference for creating your modules' +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_delegate_developer_book")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_id": ref("project.menu_action_view_task"), }) -- +- Delegate task 'Develop book for Technical and Functional reference' to these tasks and make it pending -- +- !record {model: project.task, id: project_task_documentation_book}: child_ids: - project.project_task_delegate_openerp_tutorial @@ -117,20 +127,20 @@ planned_hours: 20.0 state: pending -- +- Creating a delegate task 'Prepare documentation for Module Development' -- +- !record {model: project.task, id: project_task_delegate_module_develop}: name: Prepare documentation for Module Development planned_hours: 30.0 project_id: project.project_project_openerpdocumentation0 remaining_hours: 30.0 state: draft - -- + +- Creating a delegate 'Prepare documentation for Business Process Development' -- +- !record {model: project.task, id: project_task_delegate_business_process_develop}: name: Prepare documentation for Business Process Development planned_hours: 30.0 @@ -138,9 +148,9 @@ remaining_hours: 30.0 state: draft -- +- Delegate task 'Prepare a technical reference for creating your modules' to these tasks and make it pending -- +- !record {model: project.task, id: project_task_delegate_developer_book}: child_ids: - project.project_task_delegate_module_develop @@ -148,83 +158,84 @@ planned_hours: 20.0 state: pending -- - Open the task -- +- + Open the task 'Prepare documentation for Business Process Development' +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_delegate_module_develop")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_id": ref("project.menu_action_view_task"), }) - -- - Open the task -- + +- + Open the task 'Prepare documentation for Business Process Development' +- !python {model: project.task}: | self.do_open(cr, uid, [ref("project_task_delegate_business_process_develop")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("project.menu_action_view_task")], - "tz": False, "active_id": ref("project.menu_action_view_task"), }) + "tz": False, "active_id": ref("project.menu_action_view_task"), }) -- +- Check if 'Prepare a technical reference for creating your modules' in pending state -- +- !assert {model: project.task, id: project_task_delegate_developer_book, severity: error, string: Task must be in pending state}: - state == "pending" - -- + +- Close the child task 'Prepare documentation for Module Development' -- +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_delegate_module_develop")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_model": "ir.ui.menu", "section_id": False, "search_default_project_id": False, "search_default_user_id": 1, "search_default_current": 1, "mail_send": False, "active_id": ref("project.menu_action_view_task"), }) - -- + +- Close the child task 'Prepare documentation for Business Process Development' -- +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_delegate_business_process_develop")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_model": "ir.ui.menu", "section_id": False, "search_default_project_id": False, "search_default_user_id": 1, "search_default_current": 1, "mail_send": False, "active_id": ref("project.menu_action_view_task"), }) - -- + +- Parent task 'Prepare a technical reference for creating your modules' task must now be in open state -- +- !assert {model: project.task, id: project_task_delegate_developer_book, severity: error, string: Task is in done state}: - state == "open" - - -- + + +- Check if task 'Develop book for Technical and Functional reference' in pending state -- +- !assert {model: project.task, id: project_task_documentation_book, severity: error, string: Task is in pending state}: - state == "pending" - -- + +- Close the child task 'Prepare a technical reference for creating your modules' -- +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_delegate_developer_book")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_model": "ir.ui.menu", "section_id": False, "search_default_project_id": False, "search_default_user_id": 1, "search_default_current": 1, "mail_send": False, "active_id": ref("project.menu_action_view_task"), }) - -- - Close the child task 'Prepare a book that gives functional overview of OpenERP' -- + +- + Close the child task 'Prepare a book that gives functional overview of OpenERP' +- !python {model: project.task}: | self.do_close(cr, uid, [ref("project_task_delegate_openerp_tutorial")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")], "tz": False, "active_model": "ir.ui.menu", "section_id": False, "search_default_project_id": False, "search_default_user_id": 1, "search_default_current": 1, "mail_send": False, "active_id": ref("project.menu_action_view_task"), }) - -- - Parent task 'Develop book for Technical and Functional reference' must be now in open state -- + +- + Parent task 'Develop book for Technical and Functional reference' must be now in open state +- !assert {model: project.task, id: project_task_documentation_book, severity: error, string: Task is in done state}: - - state == "open" + - state == "open" +-