Skip to content

Commit d75d27c

Browse files
authored
Fix #81 -- Finish machine tasks (#83)
1 parent da01823 commit d75d27c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

joeflow/tasks/machine.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from django.utils import timezone
55

6+
from ..typing import MACHINE
7+
68
__all__ = (
79
"Start",
810
"Join",
@@ -51,7 +53,8 @@ def end(self):
5153

5254
def __call__(self, **kwargs):
5355
workflow = self.workflow_cls.objects.create(**kwargs)
54-
task = workflow.task_set.create(name=self.name, workflow=workflow)
56+
task = workflow.task_set.create(name=self.name, type=MACHINE, workflow=workflow)
57+
task.finish()
5558
task.start_next_tasks()
5659
return workflow
5760

tests/fixtures/simpleworkflow_instance.dot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ digraph {
33
node [fillcolor=white fontname="sans-serif" shape=rect style=filled]
44
end [color="#888888" fontcolor="#888888" style=filled]
55
"save the princess" [color=black fontcolor=black href="/simple/save_the_princess/2/" peripheries=1 style="filled, rounded, bold"]
6-
"start method" [color=black fontcolor=black peripheries=1 style="filled, bold"]
6+
"start method" [color=black fontcolor=black peripheries=1 style=filled]
77
"start view" [color="#888888" fontcolor="#888888" style="filled, rounded"]
88
"save the princess" -> end [color="#888888"]
99
"start method" -> "save the princess" [color=black]

tests/tasks/test_machine.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ def test_call(self, db):
1212
wf = workflows.SimpleWorkflow.start_method(pk=3)
1313
assert wf.pk == 3
1414

15+
start_task = wf.task_set.get(name="start_method")
16+
assert start_task.type == "machine"
17+
assert start_task.status == "succeeded"
18+
1519

1620
class TestJoin:
1721
def test_init(self):

tests/test_views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ def test_create_task(self, db, admin_client, admin_user):
2222
assert response.status_code == 302
2323

2424
wf = workflows.SimpleWorkflow.objects.get()
25-
2625
assert wf.task_set.count() == 2
26+
27+
start_task = wf.task_set.get(name="start_view")
28+
assert start_task.type == "human"
29+
assert start_task.status == "succeeded"
30+
2731
new_task = wf.task_set.get(name="save_the_princess")
28-
assert new_task.name == "save_the_princess"
2932
assert new_task.type == "human"
33+
assert new_task.status == "scheduled"
3034
assert not new_task.assignees.all()
3135

3236
def test_custom_create_task(self, db, admin_client, admin_user):
@@ -35,7 +39,7 @@ def test_custom_create_task(self, db, admin_client, admin_user):
3539
assert response.status_code == 302
3640

3741
wf = workflows.AssigneeWorkflow.objects.get()
38-
3942
assert wf.task_set.count() == 2
43+
4044
new_task = wf.task_set.get(name="save_the_princess")
4145
assert admin_user in new_task.assignees.all()

0 commit comments

Comments
 (0)