From 21e5abe8a289810b172cbf98bd4477d1ad45fe3a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Mar 2013 12:09:38 +0100 Subject: [PATCH] [ADD] add test data for goal plan bzr revid: mat@openerp.com-20130315110938-np60znn9ffjiymzc --- addons/gamification/__openerp__.py | 3 ++ addons/gamification/goal.py | 1 - addons/gamification/plan.py | 3 +- addons/gamification/test/goal_demo.yml | 39 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 addons/gamification/test/goal_demo.yml diff --git a/addons/gamification/__openerp__.py b/addons/gamification/__openerp__.py index c01b1a31a90..8ba96c5e564 100644 --- a/addons/gamification/__openerp__.py +++ b/addons/gamification/__openerp__.py @@ -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'], diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 316d848a1dc..de9802c5688 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -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)} diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py index 928127446a1..6778083df2a 100644 --- a/addons/gamification/plan.py +++ b/addons/gamification/plan.py @@ -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: diff --git a/addons/gamification/test/goal_demo.yml b/addons/gamification/test/goal_demo.yml new file mode 100644 index 00000000000..8499dbf510e --- /dev/null +++ b/addons/gamification/test/goal_demo.yml @@ -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 \ No newline at end of file