Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit ee0690c

Browse files
authored
Fix get_numeric_assignment for boolean feature flag, should return None (#25)
* Add test for expected behavior * Code change to fix test * Run autoformat
1 parent 9559074 commit ee0690c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

eppo_client/variation_type.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def is_expected_type(
1616
if expected_variation_type == cls.STRING:
1717
return isinstance(assigned_variation.typedValue, str)
1818
elif expected_variation_type == cls.NUMERIC:
19-
return isinstance(assigned_variation.typedValue, Number)
19+
return isinstance(assigned_variation.typedValue, Number) and not isinstance(
20+
assigned_variation.typedValue, bool
21+
)
2022
elif expected_variation_type == cls.BOOLEAN:
2123
return isinstance(assigned_variation.typedValue, bool)
2224
elif expected_variation_type == cls.JSON:

test/client_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,14 @@ def get_assignments(test_case):
277277
)
278278
for subject in test_case.get("subjectsWithAttributes", [])
279279
]
280+
281+
282+
@pytest.mark.parametrize("test_case", test_data)
283+
def test_get_numeric_assignment_on_bool_feature_flag_should_return_none(test_case):
284+
if test_case["valueType"] == "boolean":
285+
assignments = get_assignments(test_case=test_case)
286+
assert assignments == test_case["expectedAssignments"]
287+
# Change to get_numeric_assignment and try again
288+
test_case["valueType"] = "numeric"
289+
assignments = get_assignments(test_case=test_case)
290+
assert assignments == [None] * len(test_case["expectedAssignments"])

0 commit comments

Comments
 (0)