Skip to content

Commit b5d55f2

Browse files
yoodan93Daniel Yoo
authored and
Daniel Yoo
committed
Improve choice rule documentation
1 parent 1f7d4e3 commit b5d55f2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def IsNull(cls, variable, value):
613613
614614
Args:
615615
variable (str): Path to the variable to compare.
616-
value (bool): Whether the value at variable is equal to the JSON literal null or not.
616+
value (bool): Whether the value at `variable` is equal to the JSON literal null or not.
617617
618618
Returns:
619619
Rule: Rule with `IsNull` operator.
@@ -627,7 +627,7 @@ def IsPresent(cls, variable, value):
627627
628628
Args:
629629
variable (str): Path to the variable to compare.
630-
value (bool): Whether a field at variable exists in the input or not.
630+
value (bool): Whether a field at `variable` exists in the input or not.
631631
632632
Returns:
633633
Rule: Rule with `IsPresent` operator.
@@ -641,7 +641,7 @@ def IsString(cls, variable, value):
641641
642642
Args:
643643
variable (str): Path to the variable to compare.
644-
value (bool): Whether the value at variable is a string or not.
644+
value (bool): Whether the value at `variable` is a string or not.
645645
646646
Returns:
647647
Rule: Rule with `IsString` operator.
@@ -655,7 +655,7 @@ def IsNumeric(cls, variable, value):
655655
656656
Args:
657657
variable (str): Path to the variable to compare.
658-
value (bool): Whether the value at variable is a number or not.
658+
value (bool): Whether the value at `variable` is a number or not.
659659
660660
Returns:
661661
Rule: Rule with `IsNumeric` operator.
@@ -669,7 +669,7 @@ def IsTimestamp(cls, variable, value):
669669
670670
Args:
671671
variable (str): Path to the variable to compare.
672-
value (bool): Whether the value at variable is a timestamp or not.
672+
value (bool): Whether the value at `variable` is a timestamp or not.
673673
674674
Returns:
675675
Rule: Rule with `IsTimestamp` operator.
@@ -683,7 +683,7 @@ def IsBoolean(cls, variable, value):
683683
684684
Args:
685685
variable (str): Path to the variable to compare.
686-
value (bool): Whether the value at variable is a boolean or not.
686+
value (bool): Whether the value at `variable` is a boolean or not.
687687
688688
Returns:
689689
Rule: Rule with `IsBoolean` operator.
@@ -697,7 +697,9 @@ def StringMatches(cls, variable, value):
697697
698698
Args:
699699
variable (str): Path to the variable to compare.
700-
value (bool): Constant value to compare `variable` against.
700+
value (str): A string pattern that may contain one or more `*` characters to compare the value at `variable` to.
701+
The `*` character can be escaped using two backslashes.
702+
The comparison yields true if the variable matches the pattern, where `*` is a wildcard that matches zero or more characters.
701703
702704
Returns:
703705
Rule: Rule with `StringMatches` operator.

Diff for: tests/unit/test_choice_rule.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ def test_variable_value_must_be_consistent():
6161
with pytest.raises(ValueError):
6262
func('$.Variable', True)
6363

64-
def test_path_function_value_must_be_consistent():
65-
path_functions = {
64+
def test_path_comparator_raises_error_when_value_is_not_a_path():
65+
path_comparators = {
6666
'StringEqualsPath',
6767
'NumericEqualsPath',
6868
'TimestampEqualsPath',
6969
'BooleanEqualsPath'
7070
}
71-
for path_function in path_functions:
72-
func = getattr(ChoiceRule, path_function)
71+
for path_comparator in path_comparators:
72+
func = getattr(ChoiceRule, path_comparator)
7373
with pytest.raises(ValueError):
7474
func('$.Variable', 'string')
7575

76-
def test_is_function_value_must_be_consistent():
77-
type_functions = {
76+
def test_is_comparator_raises_error_when_value_is_not_a_bool():
77+
type_comparators = {
7878
'IsPresent',
7979
'IsNull',
8080
'IsString',
@@ -83,14 +83,13 @@ def test_is_function_value_must_be_consistent():
8383
'IsTimestamp'
8484
}
8585

86-
for type_function in type_functions:
87-
func = getattr(ChoiceRule, type_function)
86+
for type_comparator in type_comparators:
87+
func = getattr(ChoiceRule, type_comparator)
8888
with pytest.raises(ValueError):
8989
func('$.Variable', 'string')
9090
with pytest.raises(ValueError):
9191
func('$.Variable', 101)
9292

93-
# tox -e py37 -- -s -vv tests/unit/test_choice_rule.py::test_dynamic_comparator_serialization
9493
def test_static_comparator_serialization():
9594
string_timestamp_static_comparators = {
9695
'StringEquals',

0 commit comments

Comments
 (0)