"""Return JSON of TodoNode to expect."""
return {'children': [], 'seen': False, 'todo': todo_id}
- def test_do_GET_day(self) -> None:
+ def test_do_GET_day_basics(self) -> None:
"""Test GET /day basics."""
- # pylint: disable=too-many-statements
# check undefined day
date = date_in_n_days(0)
day = self.day_dict(date)
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(self) -> None:
+ """Test GET /day displaying posted Todos (no tree structure)."""
# check GET with two Todos and Processes
- expected['make_type'] = ''
- form_data = self.post_process(1)
- form_data['title'] = 'bar'
- form_data['description'] = 'rab'
- form_data['effort'] = 0.9
- self.post_process(2, form_data)
+ date = '2024-01-01'
+ day = self.day_dict(date)
+ post_day: dict[str, object] = {'day_comment': '', 'make_type': ''}
+ self.check_post(post_day, f'/day?date={date}', 302,
+ f'/day?date={date}&make_type=')
+ library: dict[str, object]
+ library = {'Day': self.as_refs([day]), 'Process': {}, 'Todo': {}}
+ expected: dict[str, object] = {'day': date,
+ 'top_nodes': [],
+ 'make_type': '',
+ 'enablers_for': {},
+ 'disablers_for': {},
+ 'conditions_present': [],
+ 'processes': [],
+ '_library': library}
+ self.post_process(1)
+ post_proc2 = {'title': 'bar', 'description': 'rab', 'effort': 0.9}
+ self.post_process(2, post_proc2)
post_day['new_todo'] = [1, 2]
self.check_post(post_day, f'/day?date={date}', 302,
- f'/day?date={date}&make_type=foo')
+ f'/day?date={date}&make_type=')
proc1 = self.proc_as_dict(1, 'foo', 'foo', 1.1)
proc2 = self.proc_as_dict(2, 'bar', 'rab', 0.9)
- expected['_library']['Process'] = self.as_refs([proc1, proc2])
+ library['Process'] = self.as_refs([proc1, proc2])
expected['processes'] = self.as_id_list([proc1, proc2])
t1 = self.todo_as_dict(1, 1, date)
t2 = self.todo_as_dict(2, 2, date)
- expected['_library']['Todo'] = self.as_refs([t1, t2])
+ library['Todo'] = self.as_refs([t1, t2])
day['todos'] = self.as_id_list([t1, t2])
n1 = self.todo_node_as_dict(1)
n2 = self.todo_node_as_dict(2)
) -> dict[str, object]:
"""Return JSON of Process to expect."""
# pylint: disable=too-many-arguments
+ as_id_list = TestCaseWithServer.as_id_list
d = {'id': id_,
'calendarize': False,
'suppressed_steps': [],
'_versioned': {
'title': {0: title},
'description': {0: description},
- 'effort': {0: effort}
- },
- 'conditions': [c['id'] for c in conditions] if conditions else [],
- 'disables': [c['id'] for c in disables] if disables else [],
- 'enables': [c['id'] for c in enables] if enables else [],
- 'blockers': [c['id'] for c in blockers] if blockers else []}
+ 'effort': {0: effort}},
+ 'conditions': as_id_list(conditions) if conditions else [],
+ 'disables': as_id_list(disables) if disables else [],
+ 'enables': as_id_list(enables) if enables else [],
+ 'blockers': as_id_list(blockers) if blockers else []}
return d
def check_redirect(self, target: str) -> None: