Files
odoo_source/addons/project/test/test_project.yml
T
2011-01-14 01:11:01 +01:00

297 lines
12 KiB
YAML

-
Test project template feature
-
Create project 'OpenERP Training Programme'
-
!record {model: project.project, id: project_project_openerptrainingprogramme0}:
company_id: base.main_company
name: OpenERP Training Programme
-
Create task 'Technical Training' for this project
-
!record {model: project.task, id: project_task_technicaltraining0}:
date_start: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: Technical Training
planned_hours: 30.0
project_id: project_project_openerptrainingprogramme0
remaining_hours: 30.0
state: draft
-
Create task 'Functional Training' for this project
-
!record {model: project.task, id: project_task_functionaltraining0}:
date_start: !eval time.strftime('%Y-%m-%d %H:%M:%S')
name: Functional Training
planned_hours: 30.0
project_id: project_project_openerptrainingprogramme0
remaining_hours: 30.0
state: draft
-
Set project as project template
-
!python {model: project.project}: |
self.set_template(cr, uid, [ref("project_project_openerptrainingprogramme0")],
{"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"), })
-
Check if project in template state
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in template state}:
- state == "template"
-
Create new project based on this template
-
!python {model: project.project}: |
new_prj = self.duplicate_template(cr, uid, [ref("project_project_openerptrainingprogramme0")],
{"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"), })
if not new_prj:
raise Exception( "New project based on template not created")
new_id = new_prj['res_id']
new_prj = self.read(cr, uid, [new_id], ['name', 'state'])[0]
state = new_prj['state']
name = new_prj['name']
assert state == 'open', "Project in %s state. Project created from template project must be in open state"%state
-
Reset project template to normal project
-
!python {model: project.project}: |
self.reset_project(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids":
[ref("project.menu_open_view_project_all")], "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
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in open state}:
- state == "open"
-
Test for different project-states
-
Keep project pending
-
!python {model: project.project}: |
self.set_pending(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids":
[ref("project.menu_open_view_project_all")], "tz": False, "active_model":
"ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"),
})
-
Check if project in pending state
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in pending state}:
- state == "pending"
-
Cancel the project
-
!python {model: project.project}: |
self.set_cancel(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids":
[ref("project.menu_open_view_project_all")], "tz": False, "active_model":
"ir.ui.menu", "project_id": False, "active_id": ref("project.menu_open_view_project_all"),
})
-
Check if project in cancel state
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in cancel state}:
- state == "cancelled"
-
Re-open the project
-
!python {model: project.project}: |
self.set_open(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")],
"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
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: Project is in open state}:
- state == "open"
-
Test for task work allocation
-
As i cancelled my project before, i check if the task 'Technical Training' is in cancelled state
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Task is in cancelled state}:
- state == "cancelled"
-
Now in order to reactivate the task 'Technical Training', i click on the "Reactivate" button and fill the remaining hour field
-
!record {model: project.task.reevaluate, id: project_task_technicaltraining_remainingwiz0}:
remaining_hours: 30.0
- |
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})
- |
Check if task 'Technical Training' in open state and for other initial values
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Project is in open state}:
- state == "open"
- planned_hours == 30
- remaining_hours == 30
- delay_hours == 0.0
- effective_hours == 0.0
-
Make a work task entry 'Training on OpenERP modules, models and classes' of 10 hours
-
!record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}:
work_ids:
- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
hours: 10.0
name: Training on OpenERP modules, models and classes
user_id: base.user_root
-
Check for effective hours and remaining hours, effective_hours must be equal to 10
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After work task of 10 hours effective_hours must be equal to 10}:
- remaining_hours == 20
- effective_hours == 10.0
-
Make a work task entry 'Training on OpenERP xml views' of 10 hours
-
!record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}:
work_ids:
- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
hours: 10.0
name: Training on OpenERP xml views
user_id: base.user_root
-
Check for effective hours and remaining hours, effective_hours must be equal to 20
-
!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 20}:
- remaining_hours == 10
- effective_hours == 20.0
-
Make a work task entry 'Training on workflows' of 10 hours
-
!record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}:
work_ids:
- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
hours: 10.0
name: Training on workflows
user_id: base.user_root
-
Check for effective hours and remaining hours, effective_hours must be equal to 30
-
!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
-
Set remaining hours of 10 hours for reevaluating the task
-
!record {model: project.task.reevaluate, id: config_compute_remaining_0}:
remaining_hours: 10.0
-
Reevaluate the task
-
!python {model: project.task.reevaluate}: |
self.compute_hours(cr, uid, [ref("config_compute_remaining_0")], {"lang": "en_US",
"project_id": False, "tz": False, "active_model": "project.task", "search_default_project_id":
False, "search_default_user_id": 1, "search_default_current": 1, "active_ids":
[ref("project_task_technicaltraining0")], "active_id": ref("project_task_technicaltraining0"), })
-
Check for effective hours and remaining hours, remaining_hours must be 10 while planned_hours remains 30
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After reevaluating the task with 10 hours remaining_hours must be 10 while planned_hours remains 30}:
- planned_hours == 30
- remaining_hours == 10.0
- effective_hours == 30.0
-
Make a work task entry 'Training on reports and wizards' of 10 hours
-
!record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}:
work_ids:
- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
hours: 10.0
name: Training on reports and wizards
user_id: base.user_root
-
Check for effective hours and remaining hours
-
!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 40 while planned_hours remains 30}:
- planned_hours == 30
- remaining_hours == 0
- effective_hours == 40.0
-
Close the task
-
!python {model: project.task}: |
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False})
-
Check if task in done state
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Task is in done state}:
- state == "done"
-
Test for task reactivation
-
Reactivate task
-
!record {model: project.task.reevaluate, id: config_compute_remaining_1}:
remaining_hours: 10.0
-
Reevaluate the task with 10 hours remaining
-
!python {model: project.task.reevaluate}: |
self.compute_hours(cr, uid, [ref("config_compute_remaining_1")], {"lang": "en_US",
"project_id": False, "tz": False, "button_reactivate": True, "active_model":
"project.task", "search_default_project_id": False, "search_default_user_id":
1, "search_default_current": 1, "active_ids": [ref("project_task_technicaltraining0")], "active_id": ref("project_task_technicaltraining0"),
})
-
Check for effective hours and remaining hours, remaining_hours must be 10 while planned_hours remains 30
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After reevaluating the task with 10 hours remaining_hours must be 10 while planned_hours remains 30}:
- planned_hours == 30
- remaining_hours == 10.0
- effective_hours == 40.0
-
Make a work task entry 'Training on yml' of 5 hours
-
!record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}:
work_ids:
- date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
hours: 5.0
name: Training on yml
user_id: base.user_root
-
Check for effective hours and remaining hours, remaining_hours must be 5, effective_hours must be 45
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After work task of 5 hours effective_hours must be equal to 45 and remaining_hours is 5}:
- planned_hours == 30
- remaining_hours == 5.0
- effective_hours == 45.0
-
Close the task
-
!python {model: project.task}: |
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False})
-
Check if task in done state
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error}:
- state == "done"
-
Check for effective hours and remaining hours
-
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: After closing the task planned_hours must remain 30 effective_hours must be 45 and remaining hours must be 0}:
- planned_hours == 30
- remaining_hours == 0.0
- effective_hours == 45.0
-
Close project 'OpenERP Training Programme'
-
!python {model: project.project}: |
self.set_done(cr, uid, [ref("project_project_openerptrainingprogramme0")], {"lang": "en_US", "active_ids": [ref("project.menu_open_view_project_all")],
"tz": False, "active_model": "ir.ui.menu", "project_id": False, "active_id":
ref("project.menu_open_view_project_all"), })
-
Check if project in close state
-
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error, string: "Project must be in closed state"}:
- state == "close"