Skip to content

Commit 6563f1d

Browse files
committedMay 13, 2021
Divide test in two and extract CONTRIBUTING.md changes into another PR
1 parent eb6fc49 commit 6563f1d

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed
 

‎CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Before sending us a pull request, please ensure that:
5757
### Running the Unit Tests
5858

5959
1. Install tox using `pip install tox`
60+
1. Install test dependencies, including coverage, using `pip install .[test]`
6061
1. cd into the aws-step-functions-data-science-sdk-python folder: `cd aws-step-functions-data-science-sdk-python` or `cd /environment/aws-step-functions-data-science-sdk-python`
61-
1. Install test dependencies, including coverage, using `pip install ".[test]"`
6262
1. Run the following tox command and verify that all code checks and unit tests pass: `tox tests/unit`
6363

6464
You can also run a single test with the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
@@ -80,7 +80,7 @@ You should only worry about manually running any new integration tests that you
8080

8181
1. Create a new git branch:
8282
```shell
83-
git checkout -b my-fix-branch main
83+
git checkout -b my-fix-branch master
8484
```
8585
1. Make your changes, **including unit tests** and, if appropriate, integration tests.
8686
1. Include unit tests when you contribute new features or make bug fixes, as they help to:

‎src/stepfunctions/steps/states.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,14 @@ 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. Setting default to make it chainable.
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.
227+
# See language spec for more info: https://states-language.net/spec.html#choice-state
225228
if self.type is 'Choice':
226229
if self.default is not None:
227230
logger.warning(
228-
"Chaining Choice Step: Overwriting %s's current default_choice (%s) with %s",
231+
"Chaining Choice state: Overwriting %s's current default_choice (%s) with %s",
229232
self.state_id,
230233
self.default.state_id,
231234
next_step.state_id

‎tests/unit/test_steps.py

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

370370

371-
def test_chaining_choice(caplog):
371+
def test_chaining_choice():
372372
s1_pass = Pass('Step - One')
373373
s2_choice = Choice('Step - Two')
374374
s3_pass = Pass('Step - Three')
375375

376-
with caplog.at_level(logging.WARNING):
377-
chain1 = Chain([s1_pass, s2_choice, s3_pass])
378-
assert caplog.text == '' # No warning
376+
chain1 = Chain([s1_pass, s2_choice, s3_pass])
379377
assert chain1.steps == [s1_pass, s2_choice, s3_pass]
380378
assert s1_pass.next_step == s2_choice
381379
assert s2_choice.default == s3_pass
382380
assert s2_choice.next_step is None # Choice steps do not have next_step
383381
assert s3_pass.next_step is None
384382

383+
384+
def test_chaining_choice_with_default(caplog):
385+
s1_pass = Pass('Step - One')
386+
s2_choice = Choice('Step - Two')
387+
s3_pass = Pass('Step - Three')
388+
389+
s2_choice.default_choice(s3_pass)
390+
385391
# Chain s2_choice when default_choice is already set will trigger Warning
386392
with caplog.at_level(logging.WARNING):
387393
Chain([s2_choice, s1_pass])
388-
log_message = (
389-
"Chaining Choice Step: Overwriting %s's current default_choice (%s) with %s" %
394+
expected_warning = (
395+
"Chaining Choice state: Overwriting %s's current default_choice (%s) with %s" %
390396
(s2_choice.state_id, s3_pass.state_id, s1_pass.state_id)
391397
)
392-
assert log_message in caplog.text
398+
assert expected_warning in caplog.text
399+
assert 'WARNING' in caplog.text
393400
assert s2_choice.default == s1_pass
394401
assert s2_choice.next_step is None # Choice steps do not have next_step
395402

0 commit comments

Comments
 (0)
Please sign in to comment.