-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: EvaluationDetails.reason should be a string, Reason enum shoul…
…d export default reasons per spec (#126) Signed-off-by: James Carr <james.r.carr@gmail.com>
- Loading branch information
Showing
5 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from open_feature.exception.error_code import ErrorCode | ||
from open_feature.flag_evaluation.flag_evaluation_details import FlagEvaluationDetails | ||
from open_feature.flag_evaluation.reason import Reason | ||
|
||
|
||
def test_evaulation_details_reason_should_be_a_string(): | ||
# Given | ||
flag_key = "my-flag" | ||
flag_value = 100 | ||
variant = "1-hundred" | ||
reason = Reason.DEFAULT | ||
error_code = ErrorCode.GENERAL | ||
error_message = "message" | ||
|
||
# When | ||
flag_details = FlagEvaluationDetails( | ||
flag_key, | ||
flag_value, | ||
variant, | ||
reason, | ||
error_code, | ||
error_message, | ||
) | ||
|
||
# Then | ||
assert flag_key == flag_details.flag_key | ||
assert flag_value == flag_details.value | ||
assert variant == flag_details.variant | ||
assert error_code == flag_details.error_code | ||
assert error_message == flag_details.error_message | ||
assert reason.value == flag_details.reason | ||
|
||
|
||
def test_evaulation_details_reason_should_be_a_string_when_set(): | ||
# Given | ||
flag_key = "my-flag" | ||
flag_value = 100 | ||
variant = "1-hundred" | ||
reason = Reason.DEFAULT | ||
error_code = ErrorCode.GENERAL | ||
error_message = "message" | ||
|
||
# When | ||
flag_details = FlagEvaluationDetails( | ||
flag_key, | ||
flag_value, | ||
variant, | ||
reason, | ||
error_code, | ||
error_message, | ||
) | ||
flag_details.reason = Reason.STATIC | ||
|
||
# Then | ||
assert Reason.STATIC.value == flag_details.reason |