Skip to content

Commit

Permalink
Add integration test for failing tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Dec 2, 2018
1 parent 8cca794 commit 2d40dc4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from django.urls import reverse

from joeflow.models import Task
from tests.testapp import models


Expand Down Expand Up @@ -97,3 +98,12 @@ def test_change(self, db, admin_client):
url = reverse('admin:joeflow_task_change', args=[task.pk])
response = admin_client.get(url)
assert response.status_code == 200


class TestFailingProcess:
def test_fail(self, db):
process = models.FailingProcess.start()
failed_task = process.task_set.latest()
assert failed_task.status == Task.FAILED
assert failed_task.exception == 'ValueError: Boom!'
assert 'Traceback (most recent call last):' in failed_task.stacktrace
9 changes: 9 additions & 0 deletions tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ class Migration(migrations.Migration):
},
bases=('joeflow.process', models.Model),
),
migrations.CreateModel(
name='FailingProcess',
fields=[
('process_ptr',
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True,
primary_key=True, serialize=False, to='joeflow.Process')),
],
bases=('joeflow.process',),
),
]
11 changes: 11 additions & 0 deletions tests/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,14 @@ def end(self):
(start, wait),
(wait, end),
)


class FailingProcess(Process):
start = tasks.Start()

def fail(self):
raise ValueError("Boom!")

edges = (
(start, fail),
)

0 comments on commit 2d40dc4

Please sign in to comment.