Browse Source

Add test to check the job runs with the right UID. Test fails, BTW.

--HG--
extra : amend_source : 9387347e10
pull/81/head
Jairo Llopis 10 years ago
parent
commit
e7e0690fab
  1. 3
      cron_run_manually/__openerp__.py
  2. 6
      cron_run_manually/ir_cron.py
  3. 23
      cron_run_manually/tests/correct_uid.yml

3
cron_run_manually/__openerp__.py

@ -30,5 +30,8 @@ of the scheduler.
""", """,
'depends': ['base'], 'depends': ['base'],
'data': ['view/ir_cron.xml'], 'data': ['view/ir_cron.xml'],
"test": [
"tests/correct_uid.yml",
],
'installable': True, 'installable': True,
} }

6
cron_run_manually/ir_cron.py

@ -65,3 +65,9 @@ class Cron(models.Model):
self.function) self.function)
args = safe_eval('tuple(%s)' % (self.args or '')) args = safe_eval('tuple(%s)' % (self.args or ''))
return method(*args) return method(*args)
@api.model
def _current_uid(self):
"""This function returns the current UID, for testing purposes."""
return self.env.uid

23
cron_run_manually/tests/correct_uid.yml

@ -0,0 +1,23 @@
- I create a user that will run the job.
- !record {model: res.users, id: worker_user, view: False}:
company_id: base.main_company
name: worker
login: worker
password: worker
email: worker@example.com
- Create a cron job to check the UID
- !record {model: ir.cron, id: check_uid_job}:
name: Check UID
active: True
user_id: worker_user
interval_number: 1
interval_type: days
numbercall: -1
doall: False
model: ir.cron
function: _current_uid
- I execute the cron job manually to check its running UID
- !assert {model: ir.cron, id: check_uid_job}: |
self.run_manually()[0] == self.user_id
Loading…
Cancel
Save