Skip to content

Commit 2d40dc4

Browse files
committed
Add integration test for failing tasks
1 parent 8cca794 commit 2d40dc4

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

tests/test_integration.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from django.urls import reverse
88

9+
from joeflow.models import Task
910
from tests.testapp import models
1011

1112

@@ -97,3 +98,12 @@ def test_change(self, db, admin_client):
9798
url = reverse('admin:joeflow_task_change', args=[task.pk])
9899
response = admin_client.get(url)
99100
assert response.status_code == 200
101+
102+
103+
class TestFailingProcess:
104+
def test_fail(self, db):
105+
process = models.FailingProcess.start()
106+
failed_task = process.task_set.latest()
107+
assert failed_task.status == Task.FAILED
108+
assert failed_task.exception == 'ValueError: Boom!'
109+
assert 'Traceback (most recent call last):' in failed_task.stacktrace

tests/testapp/migrations/0001_initial.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,13 @@ class Migration(migrations.Migration):
6464
},
6565
bases=('joeflow.process', models.Model),
6666
),
67+
migrations.CreateModel(
68+
name='FailingProcess',
69+
fields=[
70+
('process_ptr',
71+
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True,
72+
primary_key=True, serialize=False, to='joeflow.Process')),
73+
],
74+
bases=('joeflow.process',),
75+
),
6776
]

tests/testapp/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,14 @@ def end(self):
144144
(start, wait),
145145
(wait, end),
146146
)
147+
148+
149+
class FailingProcess(Process):
150+
start = tasks.Start()
151+
152+
def fail(self):
153+
raise ValueError("Boom!")
154+
155+
edges = (
156+
(start, fail),
157+
)

0 commit comments

Comments
 (0)