Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "tests/engine_tests/engine-test-data"]
path = tests/engine_tests/engine-test-data
url = https://github.com/flagsmith/engine-test-data.git
tag = v2.2.0
tag = v2.4.0
1 change: 1 addition & 0 deletions flag_engine/context/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class EnvironmentContext(TypedDict):
class FeatureValue(TypedDict):
value: Any
weight: float
priority: int


class IdentityContext(TypedDict):
Expand Down
8 changes: 4 additions & 4 deletions flag_engine/segments/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ def get_flag_result_from_feature_context(
[feature_context["key"], key]
)

# We expect `variants` to be pre-sorted in order of persistence. This gives us a
# way to ensure that the same value is returned every time we use the same
# percentage value.
start_percentage = 0.0

for variant in variants:
for variant in sorted(
variants,
key=operator.itemgetter("priority"),
):
limit = (weight := variant["weight"]) + start_percentage
if start_percentage <= percentage_value < limit:
return {
Expand Down
2 changes: 1 addition & 1 deletion tests/engine_tests/engine-test-data
Submodule engine-test-data updated 35 files
+4 −4 test_cases/test_context_value_jsonpath_pointing_to_object__is_not_set__should_match.jsonc
+41 −0 test_cases/test_equal_boolean_false_integer_condition__should_not_match.jsonc
+54 −0 test_cases/test_equal_boolean_false_to_string__should_match.jsonc
+49 −0 test_cases/test_equal_boolean_false_to_true_string__should_not_match.jsonc
+54 −0 test_cases/test_equal_boolean_true__should_match.jsonc
+49 −0 test_cases/test_equal_boolean_true_integer_1_condition__should_match.jsonc
+46 −0 test_cases/test_equal_float__should_match.jsonc
+46 −0 test_cases/test_equal_integer_0_boolean_condition__should_not_match.jsonc
+46 −0 test_cases/test_equal_integer_1_boolean_condition__should_not_match.jsonc
+46 −0 test_cases/test_equal_integer__should_match.jsonc
+41 −0 test_cases/test_equal_integer_to_non_numeric_string__should_not_match.jsonc
+46 −0 test_cases/test_equal_string__should_match.jsonc
+41 −0 test_cases/test_equal_string_to_string__should_not_match.jsonc
+41 −0 test_cases/test_greater_than_float__equal__should_not_match.jsonc
+46 −0 test_cases/test_greater_than_float__should_match.jsonc
+46 −0 test_cases/test_greater_than_inclusive_float__equal__should_match.jsonc
+46 −0 test_cases/test_greater_than_inclusive_float__should_match.jsonc
+46 −0 test_cases/test_greater_than_inclusive_integer__equal__should_match.jsonc
+46 −0 test_cases/test_greater_than_inclusive_integer__should_match.jsonc
+46 −0 test_cases/test_greater_than_integer__should_match.jsonc
+41 −0 test_cases/test_greater_than_integer__should_not_match.jsonc
+46 −0 test_cases/test_less_than_float__should_match.jsonc
+46 −0 test_cases/test_less_than_inclusive_float_equal__should_match.jsonc
+46 −0 test_cases/test_less_than_inclusive_integer__should_match.jsonc
+41 −0 test_cases/test_less_than_inclusive_integer__should_not_match.jsonc
+46 −0 test_cases/test_less_than_inclusive_integer_equal__should_match.jsonc
+51 −0 test_cases/test_multivariate__option_a_stronger_priority__expected_flags.jsonc
+51 −0 test_cases/test_multivariate__option_b_stronger_priority__expected_flags.jsonc
+41 −0 test_cases/test_not_equal_boolean_false__should_not_match.jsonc
+46 −0 test_cases/test_not_equal_boolean_false_vs_true_string__should_not_match.jsonc
+46 −0 test_cases/test_not_equal_boolean_true_vs_false_string__should_not_match.jsonc
+46 −0 test_cases/test_not_equal_float_comparison__should_not_match.jsonc
+46 −0 test_cases/test_not_equal_number_type_conversion__should_not_match.jsonc
+46 −0 test_cases/test_not_equal_string__should_match.jsonc
+41 −0 test_cases/test_not_equal_string__should_not_match.jsonc
8 changes: 4 additions & 4 deletions tests/unit/segments/test_segments_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ def test_get_flag_result_from_feature_context__calls_returns_expected(
"name": "my_feature",
"value": "control",
"variants": [
{"value": "foo", "weight": 30},
{"value": "bar", "weight": 30},
{"value": "foo", "weight": 30, "priority": 1},
{"value": "bar", "weight": 30, "priority": 2},
],
}

Expand Down Expand Up @@ -897,8 +897,8 @@ def test_get_flag_result_from_feature_context__null_key__calls_returns_expected(
"name": "my_feature",
"value": "control",
"variants": [
{"value": "foo", "weight": 30},
{"value": "bar", "weight": 30},
{"value": "foo", "weight": 30, "priority": 1},
{"value": "bar", "weight": 30, "priority": 2},
],
}

Expand Down