[IMP] project_long_term: improve YML test cases of phase
bzr revid: hmo@tinyerp.com-20111128125328-vd4ovcibw844y0d7
This commit is contained in:
@@ -43,9 +43,7 @@ Features
|
||||
"init_xml": [],
|
||||
"demo_xml": ["project_long_term_demo.xml"],
|
||||
"test": [
|
||||
'test/schedule_project_phases.yml',
|
||||
'test/schedule_project_tasks.yml',
|
||||
'test/draft2open2close_phase.yml',
|
||||
'test/phase_process.yml',
|
||||
],
|
||||
"update_xml": [
|
||||
"security/ir.model.access.csv",
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
This Demo data file Human Resources, Phases and Resources,Tasks allocation and also run scheduling of phase and tasks.
|
||||
-->
|
||||
|
||||
<record id="project.project_integrate_openerp" model="project.project">
|
||||
<field name="resource_calendar_id" ref="resource.timesheet_group1"/>
|
||||
</record>
|
||||
|
||||
<!-- Project Phases -->
|
||||
|
||||
<record id="project_phase_1" model="project.phase">
|
||||
@@ -13,6 +17,7 @@
|
||||
<field name="product_uom" ref="product.uom_day"/>
|
||||
<field eval="1" name="sequence"/>
|
||||
<field name="duration">30</field>
|
||||
<field name="constraint_date_start" eval="time.strftime('%Y-%m-01 10:00:00')"></field>
|
||||
<field name="project_id" ref="project.project_integrate_openerp"/>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
-
|
||||
I make "Collect Requirement and Make SRS" in open state.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_open(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after put in open.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in open state}:
|
||||
- state == "open"
|
||||
-
|
||||
I make Phase in pending state because of resource problem.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_pending(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after put in pending.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in pending state}:
|
||||
- state == "pending"
|
||||
-
|
||||
I make Phase in cancel state.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_cancel(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after put in cancel.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in cancel state}:
|
||||
- state == "cancelled"
|
||||
-
|
||||
I make Phase "Design Model" in done state.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_done(cr, uid, [ref("project_phase_2")])
|
||||
-
|
||||
I check state of phase after put in done.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_2, severity: error, string: Phase should be in done state}:
|
||||
- state == "done"
|
||||
@@ -0,0 +1,79 @@
|
||||
-
|
||||
In order to test process of Phases,
|
||||
-
|
||||
I create a record to schedule the phase of project.
|
||||
-
|
||||
!record {model: project.compute.phases, id: project_compute_phases01}:
|
||||
target_project: 'one'
|
||||
project_id: project.project_integrate_openerp
|
||||
-
|
||||
I schedule the phases.
|
||||
-
|
||||
!python {model: project.compute.phases}: |
|
||||
self.check_selection(cr, uid, [ref("project_compute_phases01")])
|
||||
-
|
||||
I check the starting date and ending date on the phases after scheduling.
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
project = self.browse(cr, uid, ref("project.project_integrate_openerp"), context=context)
|
||||
def _convert(date):
|
||||
import time
|
||||
return time.strptime(date, '%Y-%m-%d %H:%M:%S')
|
||||
def _check(phase, _convert, _check): #TOFIX: why need to pass function ?
|
||||
for next_phase in phase.next_phase_ids:
|
||||
assert _convert(next_phase.date_start) >= _convert(phase.date_end), "Phase does not start in proper date."
|
||||
_check(next_phase, _convert, _check)
|
||||
return True
|
||||
|
||||
for phase in project.phase_ids:
|
||||
|
||||
assert phase.date_start, "Start date should be computed."
|
||||
assert phase.date_end, "End date should be computed."
|
||||
if not phase.previous_phase_ids and phase.constraint_date_start:
|
||||
assert _convert(phase.date_start) >= _convert(phase.constraint_date_start), "Phase does not start in proper date."
|
||||
_check(phase, _convert, _check)
|
||||
-
|
||||
I open phase.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_open(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after opened.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in open state}:
|
||||
- state == "open"
|
||||
-
|
||||
I put phase in pending state.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_pending(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after put in pending.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in pending state}:
|
||||
- state == "pending"
|
||||
-
|
||||
I make Phase in cancel state.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_cancel(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after cancelled.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in cancel state}:
|
||||
- state == "cancelled"
|
||||
-
|
||||
I put again in draft phase.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_draft(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I close phase.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
self.set_done(cr, uid, [ref("project_phase_1")])
|
||||
-
|
||||
I check state of phase after closed.
|
||||
-
|
||||
!assert {model: project.phase, id: project_phase_1, severity: error, string: Phase should be in done state}:
|
||||
- state == "done"
|
||||
@@ -1,63 +0,0 @@
|
||||
-
|
||||
I Set working period to Project 'Integrate a Sale and Warehouse Management'
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
self.write(cr, uid, [ref("project.project_integrate_openerp")], {'resource_calendar_id': ref("resource.timesheet_group1")})
|
||||
-
|
||||
I update the constrain and the "Collect Requirement and Make SRS" to not start before 4 days.
|
||||
-
|
||||
!python {model : project.phase }: |
|
||||
pass
|
||||
import datetime
|
||||
from dateutil.relativedelta import *
|
||||
start = datetime.date.today() + relativedelta(days=4)
|
||||
self.write(cr,uid, [(ref("project_phase_1"))], {'constraint_date_start': start})
|
||||
-
|
||||
I Schedule Phases of Project.
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
self.schedule_phases(cr, uid, ref("project.project_integrate_openerp"))
|
||||
-
|
||||
Now I create a record to compute the phase of project.
|
||||
-
|
||||
!record {model: project.compute.phases, id: project_compute_phases01}:
|
||||
target_project: 'one'
|
||||
project_id: project.project_integrate_openerp
|
||||
-
|
||||
I schedule the phases.
|
||||
-
|
||||
!python {model: project.compute.phases}: |
|
||||
self.check_selection(cr, uid, [ref("project_compute_phases01")])
|
||||
-
|
||||
Check if phases scheduled, check that either of phase's start_date, end_date and user_id is not null
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
prj=self.browse(cr, uid, [ref("project.project_integrate_openerp")])[0]
|
||||
for phase in prj.phase_ids:
|
||||
if (not phase.date_start) or (not phase.date_end):
|
||||
raise AssertionError("Phase not scheduled")
|
||||
-
|
||||
After scheduling, I check the starting date and ending date on the phases are correct.
|
||||
-
|
||||
!python {model: project.phase}: |
|
||||
import datetime
|
||||
from dateutil.relativedelta import *
|
||||
minstart = (datetime.date.today() + relativedelta(days=4)).strftime('%Y-%m-%d')
|
||||
minend = (datetime.date.today() + relativedelta(days=5)).strftime('%Y-%m-%d')
|
||||
|
||||
phase1=self.browse(cr, uid, ref('project_phase_1'))
|
||||
assert phase1.date_start>=minstart, 'Error, the Collect Requirement and Make SRS phase '+phase1.date_start+' should start after '+str(minstart)
|
||||
assert phase1.date_end>=minend, 'Error, the Collect Requirement and Make SRS phase should end after '+str(minend)
|
||||
|
||||
phase2=self.browse(cr, uid, ref('project_phase_2'))
|
||||
assert phase2.date_start>=phase1.date_end, 'Error, the phase Design Model should start after the end of the Collect Requirement and Make SRS phase'
|
||||
|
||||
phase3=self.browse(cr, uid, ref('project_phase_3'))
|
||||
assert phase3.date_start>=phase2.date_end, 'Error, the phase Development and Integration should start after the end of the Design Model phase'
|
||||
|
||||
phase4=self.browse(cr, uid, ref('project_phase_4'))
|
||||
assert phase4.date_start>=phase3.date_end, 'Error, the phase Review and Testing should start after the end of the Development and Integration phase'
|
||||
|
||||
phase5=self.browse(cr, uid, ref('project_phase_5'))
|
||||
assert phase5.date_start>=phase4.date_end, 'Error, the phase Deployement and Training start after the end of the Review and Testing phase'
|
||||
assert phase5.date_start<phase5.date_end, 'Error, the phase Deployement and Training start before ending'
|
||||
@@ -1,25 +0,0 @@
|
||||
-
|
||||
I create a record to compute the tasks of project.
|
||||
-
|
||||
!record {model: project.compute.tasks, id: project_compute_tasks0}:
|
||||
project_id: project.project_integrate_openerp
|
||||
-
|
||||
I compute the tasks.
|
||||
-
|
||||
!python {model: project.compute.tasks}: |
|
||||
self.compute_date(cr, uid, [ref("project_compute_tasks0")])
|
||||
-
|
||||
I Schedule tasks.
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
self.schedule_tasks(cr, uid, ref("project.project_integrate_openerp"))
|
||||
-
|
||||
Check if tasks scheduled, check that either of task's start_date, end_date and user_id is not null
|
||||
-
|
||||
!python {model: project.project}: |
|
||||
prj = self.browse(cr, uid, [ref("project.project_integrate_openerp")])[0]
|
||||
for task in prj.tasks:
|
||||
if task.state in ('done','cancelled'):
|
||||
continue
|
||||
if (not task.user_id) or (not task.date_start) or (not task.date_end):
|
||||
raise AssertionError("Project tasks not scheduled!")
|
||||
Reference in New Issue
Block a user