diff --git a/opentech/apply/tests.py b/opentech/apply/tests.py index 1d23399c62f623e1f0d17d53da2b17694696d79e..423b87a20ca71505938bff4216fa13fd4574f03b 100644 --- a/opentech/apply/tests.py +++ b/opentech/apply/tests.py @@ -6,8 +6,15 @@ from .workflow import Workflow, Stage class TestWorkflowCreation(SimpleTestCase): def test_can_create_workflow(self): name = 'single_stage' - workflow = Workflow(name) + stage = Stage('stage_name') + workflow = Workflow(name, stage) self.assertEqual(workflow.name, name) + self.assertCountEqual(workflow.stages, [stage]) + + def test_stages_required_for_workflow(self): + name = 'single_stage' + with self.assertRaises(ValueError): + Workflow(name) class TestStageCreation(SimpleTestCase): diff --git a/opentech/apply/workflow.py b/opentech/apply/workflow.py index 069be6123d17e28fb1b661e016f8966b352cbf77..5b0cbde8c0954fbf6aa55b54fdb70b302a7a2130 100644 --- a/opentech/apply/workflow.py +++ b/opentech/apply/workflow.py @@ -1,6 +1,9 @@ class Workflow: - def __init__(self, name): + def __init__(self, name, *stages): self.name = name + if not stages: + raise ValueError('Stages must be supplied') + self.stages = stages class Stage: