Skip to content
Snippets Groups Projects
Commit 4bf6d863 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add tests for the next phase action

parent e09fbdf4
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,9 @@ class PhaseFactory(factory.Factory): ...@@ -42,6 +42,9 @@ class PhaseFactory(factory.Factory):
name = factory.Faker('word') name = factory.Faker('word')
actions = ListSubFactory(ActionFactory, count=factory.SelfAttribute('num_actions')) actions = ListSubFactory(ActionFactory, count=factory.SelfAttribute('num_actions'))
stage = factory.PostGeneration(
lambda obj, create, extracted, **kwargs: StageFactory.build(phases=[obj])
)
@classmethod @classmethod
def _create(cls, model_class, *args, **kwargs): def _create(cls, model_class, *args, **kwargs):
......
from django.test import SimpleTestCase from django.test import SimpleTestCase
from django.forms import Form from django.forms import Form
from opentech.apply.workflow import Action, Phase, Stage, Workflow from opentech.apply.workflow import (
Action,
ChangePhaseAction,
NextPhaseAction,
Phase,
Stage,
Workflow,
)
from .factories import ActionFactory, PhaseFactory, StageFactory, WorkflowFactory from .factories import ActionFactory, PhaseFactory, StageFactory, WorkflowFactory
...@@ -100,3 +107,15 @@ class TestActions(SimpleTestCase): ...@@ -100,3 +107,15 @@ class TestActions(SimpleTestCase):
action = ActionFactory() action = ActionFactory()
with self.assertRaises(NotImplementedError): with self.assertRaises(NotImplementedError):
action.process('') action.process('')
class TestCustomActions(SimpleTestCase):
def test_next_phase_action_returns_none_if_no_next(self):
action = NextPhaseAction('the next!')
phase = PhaseFactory(actions=[action])
self.assertEqual(phase.process(action.name), None)
def test_next_phase_action_returns_next_phase(self):
action = NextPhaseAction('the next!')
stage = StageFactory.build(num_phases=2, phases__actions=[action])
self.assertEqual(stage.phases[0].process(action.name), stage.phases[1])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment