[MERGE] base: raise an exception if the format of the bank account is wrong
[odoo/odoo.git] / openerp / addons / base / test / test_ir_cron.yml
1 -
2   Test the cron jobs scheduling.
3 -
4   Disable the existing cron jobs if any during the tests.
5 -
6   !python {model: ir.cron }: |
7       # For this test to work, as it involves multiple database cursors,
8       # we have to commit changes. But YAML tests must be rollbacked, so
9       # the final database state is left untouched. So we have to be a bit
10       # ugly here: use our own cursor, commit, and clean after ourselves.
11       # We also pass around some ids using setattr/delattr, and we have to
12       # rollback the previous tests otherwise we won't be able to touch the
13       # db.
14       # Well, this should probably be a standalone, or regular unit test,
15       # instead of using the YAML infrastructure.
16       cr.rollback()
17       our_cr = self.pool.db.cursor()
18       try:
19           ids = self.search(our_cr, uid, [], {})
20           setattr(self, 'saved_ids', ids)
21           self.write(our_cr, uid, ids, {'active': False}, {})
22           our_cr.commit()
23       finally:
24           our_cr.close()
25 -
26   Three concurrent jobs started with a slight time gap. Assume 4 cron threads.
27   This will take about 2 minutes.
28 -
29   !python {model: ir.cron }: |
30       # Pretend initialization is already done. We the use a try/finally
31       # to reset _init correctly.
32       self.pool._init = False
33       our_cr = self.pool.db.cursor()
34       try:
35           self.test_00(our_cr, uid) # this will commit using the passed cursor
36           import openerp.cron
37           openerp.cron._thread_slots = 4
38           # Wake up this db as soon as the master cron thread starts.
39           openerp.cron.schedule_wakeup(1, self.pool.db.dbname)
40           # Pretend to be the master thread, for 4 iterations.
41           openerp.cron.runner_body()
42           openerp.cron.runner_body()
43           openerp.cron.runner_body()
44           openerp.cron.runner_body()
45       finally:
46           self.pool._init = True
47           our_cr.close()
48 -
49   Clean after ourselves.
50 -
51   !python {model: ir.cron }: |
52       our_cr = self.pool.db.cursor()
53       try:
54           ids = [x for x in self.search(our_cr, uid, ['|', ('active', '=', True), ('active', '=', False)], {}) if x not in self.saved_ids]
55           self.unlink(our_cr, uid, ids, {})
56           ids = self.saved_ids
57           delattr(self, 'saved_ids')
58           self.write(our_cr, uid, ids, {'active': True}, {})
59           our_cr.commit()
60       finally:
61           our_cr.close()