Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
fab0b6c8
Commit
fab0b6c8
authored
7 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Provide a sequence of stages for the workflow
parent
1e6b86fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/apply/tests.py
+5
-7
5 additions, 7 deletions
opentech/apply/tests.py
opentech/apply/workflow.py
+9
-4
9 additions, 4 deletions
opentech/apply/workflow.py
with
14 additions
and
11 deletions
opentech/apply/tests.py
+
5
−
7
View file @
fab0b6c8
...
...
@@ -9,18 +9,13 @@ class TestWorkflowCreation(SimpleTestCase):
def
test_can_create_workflow
(
self
):
name
=
'
single_stage
'
stage
=
StageFactory
()
workflow
=
Workflow
(
name
,
stage
)
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
)
def
test_can_iterate_through_workflow
(
self
):
stages
=
StageFactory
.
create_batch
(
2
)
workflow
=
Workflow
(
'
two_stage
'
,
*
stages
)
workflow
=
Workflow
(
'
two_stage
'
,
stages
)
for
stage
,
check
in
zip
(
workflow
,
stages
):
self
.
assertEqual
(
stage
,
check
)
...
...
@@ -32,6 +27,9 @@ class TestWorkflowCreation(SimpleTestCase):
workflow
=
WorkflowFactory
(
num_stages
=
1
)
self
.
assertEqual
(
workflow
.
next
(
workflow
.
stages
[
0
]),
None
)
def
test_returns_next_stage
(
self
):
workflow
=
WorkflowFactory
(
num_stages
=
2
)
self
.
assertEqual
(
workflow
.
next
(
workflow
.
stages
[
0
]),
workflow
.
stages
[
1
])
class
TestStageCreation
(
SimpleTestCase
):
def
test_can_create_stage
(
self
):
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/workflow.py
+
9
−
4
View file @
fab0b6c8
from
typing
import
Iterator
,
Iterable
,
Union
from
typing
import
Iterator
,
Iterable
,
Sequence
,
Union
from
django.forms
import
Form
class
Workflow
(
Iterable
[
'
Stage
'
]):
def
__init__
(
self
,
name
:
str
,
*
stages
:
'
Stage
'
)
->
None
:
def
__init__
(
self
,
name
:
str
,
stages
:
Sequence
[
'
Stage
'
]
)
->
None
:
self
.
name
=
name
if
not
stages
:
raise
ValueError
(
'
Stages must be supplied
'
)
self
.
stages
=
stages
def
__iter__
(
self
)
->
Iterator
[
'
Stage
'
]:
...
...
@@ -17,6 +15,13 @@ class Workflow(Iterable['Stage']):
if
not
current_stage
:
return
self
.
stages
[
0
]
for
i
,
stage
in
enumerate
(
self
):
if
stage
==
current_stage
:
try
:
return
self
.
stages
[
i
+
1
]
except
IndexError
:
pass
return
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment