|
16 | 16 | from environments.identities.models import Identity |
17 | 17 | from environments.identities.traits.models import Trait |
18 | 18 | from environments.models import Environment, EnvironmentAPIKey |
19 | | - from features.models import FeatureState |
| 19 | + from features.models import Feature, FeatureState |
20 | 20 |
|
21 | 21 |
|
22 | 22 | def test_map_environment_to_environment_document__valid_environment__returns_expected_document( |
@@ -263,6 +263,32 @@ def test_map_environment_to_compressed_environment_document__valid_environment__ |
263 | 263 | ) |
264 | 264 |
|
265 | 265 |
|
| 266 | +def test_map_environment_to_compressed_environment_document__mv_option_with_key__key_preserved( |
| 267 | + environment: "Environment", |
| 268 | + multivariate_feature: "Feature", |
| 269 | +) -> None: |
| 270 | + # Given |
| 271 | + mv_option = multivariate_feature.multivariate_options.first() |
| 272 | + assert mv_option is not None |
| 273 | + mv_option.key = "control" |
| 274 | + mv_option.save() |
| 275 | + |
| 276 | + # When |
| 277 | + result = dynamodb.map_environment_to_compressed_environment_document(environment) |
| 278 | + |
| 279 | + # Then |
| 280 | + feature_states = json.loads( |
| 281 | + gzip.decompress(result.document["feature_states"]).decode("utf-8") |
| 282 | + ) |
| 283 | + mv_options = [ |
| 284 | + mv_value["multivariate_feature_option"] |
| 285 | + for feature_state in feature_states |
| 286 | + for mv_value in feature_state["multivariate_feature_state_values"] |
| 287 | + ] |
| 288 | + keyed_option = next(option for option in mv_options if option["id"] == mv_option.id) |
| 289 | + assert keyed_option["key"] == "control" |
| 290 | + |
| 291 | + |
266 | 292 | def test_map_environment_to_compressed_environment_v2_document__valid_environment__returns_compressed_fields( |
267 | 293 | environment: "Environment", |
268 | 294 | feature_state: "FeatureState", |
|
0 commit comments