Skip to content

Commit dcbc967

Browse files
add tests for error cases
1 parent 7f90596 commit dcbc967

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

mixpanel/flags/test_local_feature_flags.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,30 @@ async def test_get_variant_value_respects_runtime_evaluation_rule_not_satisfied(
213213
result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context)
214214
assert result == "fallback"
215215

216+
@respx.mock
217+
async def test_get_variant_value_invalid_runtime_rule_resorts_to_fallback(self):
218+
runtime_eval = {
219+
"=oops=": [{"var": "plan"}, "premium"]
220+
}
221+
flag = create_test_flag(runtime_evaluation_rule=runtime_eval)
222+
await self.setup_flags([flag])
223+
context = self.user_context_with_properties({
224+
"plan": "basic",
225+
})
226+
result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context)
227+
assert result == "fallback"
228+
229+
@respx.mock
230+
async def test_get_variant_value_respects_runtime_evaluation_rule_not_satisfied_when_no_custom_properties_provided(self):
231+
runtime_eval = {
232+
"=": [{"var": "plan"}, "premium"]
233+
}
234+
flag = create_test_flag(runtime_evaluation_rule=runtime_eval)
235+
await self.setup_flags([flag])
236+
context = self.user_context_with_properties({})
237+
result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context)
238+
assert result == "fallback"
239+
216240
@respx.mock
217241
async def test_get_variant_value_respects_runtime_evaluation_rule_caseinsensitive_values__satisfied(self):
218242
runtime_eval = {

0 commit comments

Comments
 (0)