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

Add actions as requirement on phases

parent c60f76dc
No related branches found
No related tags found
No related merge requests found
from django.forms import Form from django.forms import Form
import factory import factory
from opentech.apply.workflow import Phase, Stage, Workflow from opentech.apply.workflow import Action, Phase, Stage, Workflow
class ListSubFactory(factory.SubFactory): class ListSubFactory(factory.SubFactory):
...@@ -26,11 +26,22 @@ class ListSubFactory(factory.SubFactory): ...@@ -26,11 +26,22 @@ class ListSubFactory(factory.SubFactory):
] ]
class ActionFactory(factory.Factory):
class Meta:
model = Action
name = factory.Faker('word')
class PhaseFactory(factory.Factory): class PhaseFactory(factory.Factory):
class Meta: class Meta:
model = Phase model = Phase
class Params:
num_actions = factory.Faker('random_int', min=1, max=5)
name = factory.Faker('word') name = factory.Faker('word')
actions = ListSubFactory(ActionFactory, count=factory.SelfAttribute('num_actions'))
class StageFactory(factory.Factory): class StageFactory(factory.Factory):
......
...@@ -3,7 +3,7 @@ from django.forms import Form ...@@ -3,7 +3,7 @@ from django.forms import Form
from opentech.apply.workflow import Action, Phase, Stage, Workflow from opentech.apply.workflow import Action, Phase, Stage, Workflow
from .factories import PhaseFactory, StageFactory, WorkflowFactory from .factories import ActionFactory, PhaseFactory, StageFactory, WorkflowFactory
class TestWorkflowCreation(SimpleTestCase): class TestWorkflowCreation(SimpleTestCase):
...@@ -49,9 +49,11 @@ class TestStageCreation(SimpleTestCase): ...@@ -49,9 +49,11 @@ class TestStageCreation(SimpleTestCase):
class TestPhaseCreation(SimpleTestCase): class TestPhaseCreation(SimpleTestCase):
def test_can_create_phase(self): def test_can_create_phase(self):
actions = ActionFactory.create_batch(2)
name = 'the_phase' name = 'the_phase'
phase = Phase(name) phase = Phase(name, actions)
self.assertEqual(phase.name, name) self.assertEqual(phase.name, name)
self.assertEqual(phase.actions, actions)
class TestActions(SimpleTestCase): class TestActions(SimpleTestCase):
......
...@@ -54,9 +54,10 @@ class Stage(Iterable['Phase']): ...@@ -54,9 +54,10 @@ class Stage(Iterable['Phase']):
class Phase: class Phase:
def __init__(self, name: str) -> None: def __init__(self, name: str, actions: Sequence['Action']) -> None:
self.name = name self.name = name
self.stage: Union['Stage', None] = None self.stage: Union['Stage', None] = None
self.actions = actions
self.occurance = 0 self.occurance = 0
def __str__(self): def __str__(self):
...@@ -64,7 +65,7 @@ class Phase: ...@@ -64,7 +65,7 @@ class Phase:
class Action: class Action:
def __init__(self, name: str): def __init__(self, name: str) -> None:
self.name = name self.name = name
...@@ -74,17 +75,19 @@ class ReviewPhase(Phase): ...@@ -74,17 +75,19 @@ class ReviewPhase(Phase):
pass pass
internal_review = ReviewPhase('Under Review') next_phase = Action('next')
internal_review = ReviewPhase('Under Review', [next_phase])
ac_review = ReviewPhase('Under Review') ac_review = ReviewPhase('Under Review', [next_phase])
response = Phase('Ready to Respond') response = Phase('Ready to Respond', [next_phase])
rejected = Phase('Rejected') rejected = Phase('Rejected', [next_phase])
accepted = Phase('Accepted') accepted = Phase('Accepted', [next_phase])
progress = Phase('Progress') progress = Phase('Progress', [next_phase])
standard_stage = Stage('Standard', Form(), [internal_review, response, ac_review, response, accepted, rejected]) standard_stage = Stage('Standard', Form(), [internal_review, response, ac_review, response, accepted, rejected])
......
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