effort = self._form_data.get_str('effort', ignore_strict=True)
todo.effort = float(effort) if effort else None
todo.set_conditions(self.conn,
- self._form_data.get_all_int('condition'))
- todo.set_blockers(self.conn, self._form_data.get_all_int('blocker'))
+ self._form_data.get_all_int('conditions'))
+ todo.set_blockers(self.conn, self._form_data.get_all_int('blockers'))
todo.set_enables(self.conn, self._form_data.get_all_int('enables'))
todo.set_disables(self.conn, self._form_data.get_all_int('disables'))
todo.is_done = len(self._form_data.get_all_str('done')) > 0
process.description.set(self._form_data.get_str('description'))
process.effort.set(self._form_data.get_float('effort'))
process.set_conditions(self.conn,
- self._form_data.get_all_int('condition'))
- process.set_blockers(self.conn, self._form_data.get_all_int('blocker'))
+ self._form_data.get_all_int('conditions'))
+ process.set_blockers(self.conn,
+ self._form_data.get_all_int('blockers'))
process.set_enables(self.conn, self._form_data.get_all_int('enables'))
process.set_disables(self.conn,
self._form_data.get_all_int('disables'))
'_library': {'Day': TestsWithServer.as_refs([day])}}
return d
- def post_day(self, params: str,
+ def post_day(self, params: str = '',
form_data: None | dict[str, object] = None,
redir_to: str = '',
status: int = 302,
day = expected['_library']['Day'][date]
day['comment'] = post['day_comment']
self.check_json_get(f'/day?date={date}', expected)
- # check GET parameter of a POST does not affect reply to param-free GET
+ # check GET parameter to GET requests affects immediate reply, but …
+ expected['make_type'] = 'bar'
+ self.check_json_get(f'/day?date={date}&make_type=bar', expected)
+ # … not any following, …
+ expected['make_type'] = ''
+ self.check_json_get(f'/day?date={date}', expected)
+ # … not even when part of a POST request
post['make_type'] = 'foo'
self.post_day(f'date={date}', post)
self.check_json_get(f'/day?date={date}', expected)
- expected['make_type'] = 'bar'
- self.check_json_get(f'/day?date={date}&make_type=bar', expected)
- def test_do_GET_day_with_todos_flat(self) -> None:
- """Test GET /day displaying posted Todos (no tree structure)."""
- # post two Todos of differing processes and check their display
+ def test_do_GET_day_with_processes_and_todos(self) -> None:
+ """Test GET /day displaying Processes and Todos."""
date = '2024-01-01'
- self.post_day(f'date={date}')
- expected = self.get_day_dict(date)
+ # check Processes get displayed in ['processes'] and ['_library']
post_proc1 = {'title': 'foo', 'description': 'oof', 'effort': 1.1}
post_proc2 = {'title': 'bar', 'description': 'rab', 'effort': 0.9}
- procs: list[dict[str, object]] = [{}, {}]
+ procs_expected: list[dict[str, object]] = [{}, {}]
for i, post in enumerate([post_proc1, post_proc2]):
self.post_process(i+1, post)
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'])
+ procs_expected[i] = self.proc_as_dict(i+1, post['title'],
+ post['description'],
+ post['effort'])
+ self.post_day(f'date={date}')
+ expected = self.get_day_dict(date)
+ expected['processes'] = self.as_id_list(procs_expected)
+ assert isinstance(expected['_library'], dict)
+ expected['_library']['Process'] = self.as_refs(procs_expected)
+ self.check_json_get(f'/day?date={date}', expected)
+ # post Todos of either process and check their display
post_day: dict[str, object]
post_day = {'day_comment': '', 'make_type': '', 'new_todo': [1, 2]}
self.post_day(f'date={date}', post_day)
- assert isinstance(expected['_library'], dict)
- expected['_library']['Process'] = self.as_refs(procs)
- expected['processes'] = self.as_id_list(procs)
todos = [self.todo_as_dict(1, 1, date), self.todo_as_dict(2, 2, date)]
expected['_library']['Todo'] = self.as_refs(todos)
expected['_library']['Day'][date]['todos'] = self.as_id_list(todos)
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_names = ('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['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]]
+ for j, cond_name in enumerate(cond_names):
+ post[cond_name] = [cond_vals[i][j]]
+ procs[i][cond_name] = [cond_vals[i][j]]
self.post_process(i+1, post)
date = '2024-01-01'
expected = self.get_day_dict(date)