Skip to content

Commit 851023f

Browse files
committed
Renamed tests and added chaining choice states info in docstings
1 parent 6563f1d commit 851023f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Diff for: src/stepfunctions/steps/states.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,8 @@ def next(self, next_step):
221221
if self.type in ('Succeed', 'Fail'):
222222
raise ValueError('Unexpected State instance `{step}`, State type `{state_type}` does not support method `next`.'.format(step=next_step, state_type=self.type))
223223

224-
# By design, Choice states do not have the Next field. Their purpose is to define conditional transitions based
225-
# on a set of Choice Rules. They can be viewed as an advanced Next field with multiple possible transitions.
226-
# default_choice() sets the default transition to use in the case where none of the Choice Rules are met.
224+
# By design, Choice states do not have the Next field. When used in a chain, the subsequent step becomes the
225+
# default choice that executes if none of the specified rules match.
227226
# See language spec for more info: https://states-language.net/spec.html#choice-state
228227
if self.type is 'Choice':
229228
if self.default is not None:
@@ -417,7 +416,7 @@ def allowed_fields(self):
417416
class Choice(State):
418417

419418
"""
420-
Choice state adds branching logic to a state machine. The state holds a list of *rule* and *next_step* pairs. The interpreter attempts pattern-matches against the rules in list order and transitions to the state or chain specified in the *next_step* field on the first *rule* where there is an exact match between the input value and a member of the comparison-operator array.
419+
Choice state adds branching logic to a state machine. The state holds a list of *rule* and *next_step* pairs. The interpreter attempts pattern-matches against the rules in list order and transitions to the state or chain specified in the *next_step* field on the first *rule* where there is an exact match between the input value and a member of the comparison-operator array. When used in a chain, the subsequent step becomes the default choice that executes if none of the specified rules match.
421420
"""
422421

423422
def __init__(self, state_id, **kwargs):

Diff for: tests/unit/test_steps.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def test_chaining_steps():
368368
assert s2.next_step == s3
369369

370370

371-
def test_chaining_choice():
371+
def test_chaining_choice_sets_default_field():
372372
s1_pass = Pass('Step - One')
373373
s2_choice = Choice('Step - Two')
374374
s3_pass = Pass('Step - Three')
@@ -381,7 +381,7 @@ def test_chaining_choice():
381381
assert s3_pass.next_step is None
382382

383383

384-
def test_chaining_choice_with_default(caplog):
384+
def test_chaining_choice_with_existing_default_overrides_value(caplog):
385385
s1_pass = Pass('Step - One')
386386
s2_choice = Choice('Step - Two')
387387
s3_pass = Pass('Step - Three')

0 commit comments

Comments
 (0)