- # pylint: disable=too-many-locals
- post_cond1 = {'title': 'A', 'description': '', 'is_active': False}
- post_cond2 = {'title': 'B', 'description': '', 'is_active': True}
- conds: list[dict[str, object]] = [{}, {}]
- for i, post in enumerate([post_cond1, post_cond2]):
- self.check_post(post, f'/condition?id={i+1}', 302)
- assert isinstance(post['is_active'], bool)
- assert isinstance(post['title'], str)
- assert isinstance(post['description'], str)
- conds[i] = self.cond_as_dict(i+1, post['is_active'],
- [post['title']],
- [post['description']])
- post_proc1 = {'title': 'foo', 'description': 'oof', 'effort': 1.1}
- post_proc2 = {'title': 'bar', 'description': 'rab', 'effort': 0.9}
- procs: list[dict[str, object]] = [{}, {}]
- names_input = ('condition', 'disables', 'blocker', 'enables')
- names_output = ('conditions', 'disables', 'blockers', 'enables')
- cond_vals = ((1, 1, 2, 2), (2, 2, 1, 1))
- for i, post in enumerate([post_proc1, post_proc2]):
- assert isinstance(post['title'], str)
- assert isinstance(post['description'], str)
- assert isinstance(post['effort'], float)
- procs[i] = self.proc_as_dict(i+1, post['title'],
- post['description'], post['effort'])
- for j, name_input in enumerate(names_input):
- post[name_input] = [cond_vals[i][j]]
- procs[i][names_output[j]] = [cond_vals[i][j]]
- self.post_process(i+1, 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)