Expected)
from plomtask.processes import Process, ProcessStep
from plomtask.conditions import Condition
-from plomtask.exceptions import HandledException, NotFoundException
-from plomtask.todos import Todo
+from plomtask.exceptions import NotFoundException
class TestsSansDB(TestCaseSansDB):
step = ProcessStep(None, p2.id_, p1.id_, None)
p2.set_steps(self.db_conn, [step])
step_id = step.id_
- with self.assertRaises(HandledException):
- p1.remove(self.db_conn)
p2.set_steps(self.db_conn, [])
with self.assertRaises(NotFoundException):
+ # check unset ProcessSteps actually cannot be found anymore
assert step_id is not None
ProcessStep.by_id(self.db_conn, step_id)
p1.remove(self.db_conn)
step = ProcessStep(None, p2.id_, p3.id_, None)
p2.set_steps(self.db_conn, [step])
step_id = step.id_
+ # check _can_ remove Process pointed to by ProcessStep.owner_id, and …
p2.remove(self.db_conn)
with self.assertRaises(NotFoundException):
+ # … being dis-owned eliminates ProcessStep
assert step_id is not None
ProcessStep.by_id(self.db_conn, step_id)
- todo = Todo(None, p3, False, '2024-01-01')
- todo.save(self.db_conn)
- with self.assertRaises(HandledException):
- p3.remove(self.db_conn)
- todo.remove(self.db_conn)
- p3.remove(self.db_conn)
class TestsWithDBForProcessStep(TestCaseWithDB):
self.check_json_get('/process?id=1', exp)
# check cannot delete if Todos to Process
self.check_post({'delete': ''}, '/process?id=1', 500)
+ # check cannot delete if some ProcessStep's .step_process_id
+ self.post_exp_process([exp], valid_post, 2)
+ self.post_exp_process([exp], valid_post | {'new_top_step': 2}, 3)
+ self.check_post({'delete': ''}, '/process?id=2', 500)
# check successful deletion
- self.post_exp_process([], valid_post, 2)
- self.check_post({'delete': ''}, '/process?id=2', 302, '/processes')
- exp = ExpectedGetProcess(2)
+ self.post_exp_process([exp], valid_post, 4)
+ self.check_post({'delete': ''}, '/process?id=4', 302, '/processes')
+ exp = ExpectedGetProcess(4)
exp.set_proc_from_post(1, valid_post)
- exp.force('process_candidates', [1])
- self.check_json_get('/process?id=2', exp)
+ exp.set_proc_from_post(2, valid_post)
+ exp.set_proc_from_post(3, valid_post)
+ exp.lib_set('ProcessStep', [exp.procstep_as_dict(1, 3, 2)])
+ exp.force('process_candidates', [1, 2, 3])
+ self.check_json_get('/process?id=4', exp)
def test_POST_process_steps(self) -> None:
"""Test behavior of ProcessStep posting."""