|
4 | 4 | import httpx |
5 | 5 | import threading |
6 | 6 | from unittest.mock import Mock, patch |
7 | | -from typing import Dict, Optional, List |
| 7 | +from typing import Any, Dict, Optional, List |
8 | 8 | from itertools import chain, repeat |
9 | 9 | from .types import LocalFlagsConfig, ExperimentationFlag, RuleSet, Variant, Rollout, FlagTestUsers, ExperimentationFlags, VariantOverride, SelectedVariant |
10 | 10 | from .local_feature_flags import LocalFeatureFlagsProvider |
@@ -222,19 +222,20 @@ async def test_get_variant_value_respects_runtime_evaluation_rule_not_satisfied( |
222 | 222 | } |
223 | 223 | result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context) |
224 | 224 | assert result == "fallback" |
| 225 | + |
| 226 | + def user_context_with_properties(self, properties: Dict[str, Any]) -> Dict[str, Any]: |
| 227 | + context = {"distinct_id": DISTINCT_ID, "custom_properties": properties} |
| 228 | + return context |
225 | 229 |
|
226 | 230 | @respx.mock |
227 | 231 | async def test_get_variant_value_respects_runtime_evaluation_satisfied(self): |
228 | 232 | runtime_eval = {"plan": "premium", "region": "US"} |
229 | 233 | flag = create_test_flag(runtime_evaluation_legacy_definition=runtime_eval) |
230 | 234 | await self.setup_flags([flag]) |
231 | | - context = { |
232 | | - "distinct_id": DISTINCT_ID, |
233 | | - "custom_properties": { |
234 | | - "plan": "premium", |
235 | | - "region": "US" |
236 | | - } |
237 | | - } |
| 235 | + context = self.user_context_with_properties({ |
| 236 | + "plan": "premium", |
| 237 | + "region": "US" |
| 238 | + }) |
238 | 239 | result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context) |
239 | 240 | assert result != "fallback" |
240 | 241 |
|
|
0 commit comments