- # pylint: disable=too-many-locals
- conds_expected = [self.cond_as_dict(1, False, ['A'], ['a']),
- self.cond_as_dict(2, True, ['B'], ['b'])]
- for i, cond in enumerate(conds_expected):
- post = {'is_active': cond['is_active']}
- assert isinstance(cond['_versioned'], dict)
- for k in ('title', 'description'):
- post[k] = cond['_versioned'][k][0]
- self.check_post(post, f'/condition?id={i+1}', 302)
- procs_expected = [self.proc_as_dict(1, 'foo', 'oof', 1.1),
- self.proc_as_dict(2, 'bar', 'rab', 0.9)]
- cond_names = ('conditions', 'disables', 'blockers', 'enables')
- cond_vals = ((1, 1, 2, 2), (2, 2, 1, 1))
- for i, proc in enumerate(procs_expected):
- post = {}
- assert isinstance(proc['_versioned'], dict)
- for k in ('title', 'description', 'effort'):
- post[k] = proc['_versioned'][k][0]
- for j, cond_name in enumerate(cond_names):
- post[cond_name] = proc[cond_name] = [cond_vals[i][j]]
- assert isinstance(proc['id'], int)
- self.post_process(proc['id'], post)
+ conds_data = [[1, False, ['A'], ['a']], [2, True, ['B'], ['b']]]
+ conds_expected = self.post_batch(conds_data, ['is_active'],
+ ['title', 'description'],
+ self.cond_as_dict, self.post_cond)
+ cond_names = ['conditions', 'disables', 'blockers', 'enables']
+ procs_data = [[1, 'foo', 'oof', 1.1, [1], [1], [2], [2]],
+ [2, 'bar', 'rab', 0.9, [2], [2], [1], [1]]]
+ procs_expected = self.post_batch(procs_data, cond_names,
+ ['title', 'description', 'effort'],
+ self.proc_as_dict, self.post_process)