Repository: Unleash/unleash-client-python
Pull request #130 (2021-02-10 18:06:45)

Rename 'variations' property on Feature to 'variants'
# Description

Please include a summary of the change and which issue is fixed (if any).
* Rename 'variations' property from Feature object to 'variants'.  (Refactor to address root cause of #127 )

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

- [x] Unit tests
- [x] Spec Tests
- [x] Integration tests / Manual Tests

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules


Patch:
diff --git a/UnleashClient/features/Feature.py b/UnleashClient/features/Feature.py
index 2ee924f..5931292 100644
--- a/UnleashClient/features/Feature.py
+++ b/UnleashClient/features/Feature.py
@@ -21,7 +21,7 @@ class Feature:
         self.name = name
         self.enabled = enabled
         self.strategies = strategies
-        self.variations = variants
+        self.variants = variants
 
         # Stats tracking
         self.yes_count = 0
@@ -89,9 +89,9 @@ class Feature:
         variant = DISABLED_VARIATION
         is_feature_enabled = self.is_enabled(context)
 
-        if is_feature_enabled and self.variations is not None:
+        if is_feature_enabled and self.variants is not None:
             try:
-                variant = self.variations.get_variant(context)
+                variant = self.variants.get_variant(context)
                 variant['enabled'] = is_feature_enabled
             except Exception as variant_exception:
                 LOGGER.warning("Error selecting variant: %s", variant_exception)
diff --git a/UnleashClient/loader.py b/UnleashClient/loader.py
index b16db8c..eecbf70 100644
--- a/UnleashClient/loader.py
+++ b/UnleashClient/loader.py
@@ -95,7 +95,7 @@ def load_features(cache: FileCache,
                 feature_for_update.strategies = parsed_strategies
 
             if 'variants' in parsed_features[feature]:
-                feature_for_update.variations = Variants(
+                feature_for_update.variants = Variants(
                     parsed_features[feature]['variants'],
                     parsed_features[feature]['name']
                 )
diff --git a/docs/changelog.md b/docs/changelog.md
index d857120..969dbbe 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -1,4 +1,5 @@
 ## Next version
+* (Minor) Remove dangling `variations` reference in favor of `variants` verbiage.
 
 ## v3.6.1
 * (Major) Fix bug where loader didn't properly refresh variants.


Test patch:
diff --git a/tests/unit_tests/test_loader.py b/tests/unit_tests/test_loader.py
index 8ebb37b..9354dc1 100644
--- a/tests/unit_tests/test_loader.py
+++ b/tests/unit_tests/test_loader.py
@@ -72,7 +72,7 @@ def test_loader_refresh_variants(cache_full):  # noqa: F811
 
     load_features(temp_cache, in_memory_features, DEFAULT_STRATEGY_MAPPING)
 
-    assert in_memory_features["Variations"].variations.variants[0]["name"] == "VariantA"
+    assert in_memory_features["Variations"].variants.variants[0]["name"] == "VariantA"
 
 
 def test_loader_initialization_failure(cache_custom):  # noqa: F811