From d9fea5391569b095a26483abf8a84ea442352bbc Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Wed, 13 Dec 2017 11:46:56 +0000 Subject: [PATCH] Add basic next impliementation --- opentech/apply/factories.py | 3 ++- opentech/apply/tests.py | 5 +++-- opentech/apply/workflow.py | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/opentech/apply/factories.py b/opentech/apply/factories.py index a36ce4560..a20b3729a 100644 --- a/opentech/apply/factories.py +++ b/opentech/apply/factories.py @@ -11,10 +11,11 @@ class StageFactory(factory.Factory): name = factory.Faker('word') form = factory.LazyFunction(Form) -. + class WorkflowFactory(factory.Factory): class Meta: model = Workflow + inline_args = ('name', 'stages',) class Params: num_stages = factory.Faker('random_int', min=1, max=3) diff --git a/opentech/apply/tests.py b/opentech/apply/tests.py index f34052fe6..cc8a68758 100644 --- a/opentech/apply/tests.py +++ b/opentech/apply/tests.py @@ -24,8 +24,9 @@ class TestWorkflowCreation(SimpleTestCase): for stage, check in zip(workflow, stages): self.assertEqual(stage, check) - # def test_returns_none_if_no_next_stage(self): - # workflow = Workflow('two_stage', stage1, stage2) + def test_returns_first_stage_if_no_arg(self): + workflow = WorkflowFactory(num_stages=1) + self.assertEqual(workflow.next(), workflow.stages[0]) class TestStageCreation(SimpleTestCase): diff --git a/opentech/apply/workflow.py b/opentech/apply/workflow.py index d24e47187..9b624227e 100644 --- a/opentech/apply/workflow.py +++ b/opentech/apply/workflow.py @@ -13,6 +13,9 @@ class Workflow(Iterable['Stage']): def __iter__(self) -> Iterator['Stage']: yield from self.stages + def next(self): + return self.stages[0] + class Stage: def __init__(self, name: str, form: Form) -> None: -- GitLab