[ADD] add test data for goal plan

bzr revid: mat@openerp.com-20130315110938-np60znn9ffjiymzc
This commit is contained in:
Martin Trigaux 2013-03-15 12:09:38 +01:00
parent 8b6cdd23a3
commit 21e5abe8a2
4 changed files with 44 additions and 2 deletions

View File

@ -56,6 +56,9 @@ A **Badge** is a symbolic token granted to a user as a sign of reward. It can be
'demo': [
'badge_demo.xml',
],
'test': [
'test/goal_demo.yml'
],
'installable': True,
'application': True,
'css': ['static/src/css/goal.css'],

View File

@ -234,7 +234,6 @@ class gamification_goal(osv.Model):
towrite = {'current': 0}
else: # computation mode = count
print(uid, domain, type(obj))
res = obj.search(cr, uid, domain, context=context)
towrite = {'current': len(res)}

View File

@ -268,7 +268,8 @@ class gamification_goal_plan(osv.Model):
def action_start(self, cr, uid, ids, context=None):
"""Start a draft goal plan
Change the state of the plan to in progress"""
Change the state of the plan to in progress and genereate related goals
"""
# subscribe users if autojoin group
for plan in self.browse(cr, uid, ids, context=context):
if plan.autojoin_group_id:

View File

@ -0,0 +1,39 @@
-
In order to test process of the Goals, I assign the discovery goal plan to all users
-
!record {model: gamification.goal.plan, id: plan_base_discover}:
autojoin_group_id: base.group_user
-
I verify that the users of the group are added (at least admin and demo)
-
!assert {model: gamification.goal.plan, id: plan_base_discover, string: The autojoin function was not successful}:
- len(user_ids) >= 2
-
I start the goal plan and verify the change of state
-
!python {model: gamification.goal.plan}: |
plan = self.browse(cr, uid, ref('plan_base_discover'))
self.action_start(cr, uid, [plan.id], context=context)
assert plan.state == 'inprogress', "Plan failed the change of state"
-
I verify the goals are generated correctly
-
!python {model: gamification.goal}: |
goal_ids = self.search(cr, uid, [('plan_id', '=', ref('plan_base_discover'))], context=context)
assert len(goal_ids) >= 2, "Not enough goals have been generated"
for goal in self.browse(cr, uid, goal_ids, context=context):
assert goal.state != 'draft', "Draft goal have been generated"
assert goal.planline_id.plan_id.id == ref('plan_base_discover'), "Linked planline incorrect"
-
I change timezone for demo user
-
!record {model: res.users, id: base.user_demo}:
tz: "Europe/Brussels"
-
I check the goal for demo user is successful
-
!python {model: gamification.goal}: |
goal_ids = self.search(cr, uid, [('user_id', '=', ref('base.user_demo'))])
self.update(cr, uid, goal_ids, context=context)
for goal in self.browse(cr, uid, goal_ids, context=context):
assert goal.state == "reached", "Goal not successful %s" % goal.state