Skip to content

Commit e557d54

Browse files
authored
Validation tests (#20)
* Fixing issues found when targeting users * Adding some comments and fixing a few tests * Updated Theta test description * removing debug steps * Split file into multiple * Cleaning Up * removed old file * More tests, fixed default enabled value. * Enabled should be a boolean * Update test_no_filters_from_file.py * Updated to json tests * formatting * Map to list * Update test_json_validations.py * Updated from changes in App Config repo * Updating with PyLint * Update test_json_validations.py * Updated to match AppConfiguration repo * Trying out submodule * Delete --force * Update TestFiles * Removing submodule * Updating Tests * single quotes * single quotes in tests * Updated schema * Updated to fix tests * Update _defaultfilters.py
1 parent f4403d7 commit e557d54

17 files changed

+1056
-399
lines changed

featuremanagement/_defaultfilters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def _target_group(self, target_user, target_group, group, feature_flag_name):
9292
group_rollout_percentage = group.get(ROLLOUT_PERCENTAGE_KEY, 0)
9393
if not target_user:
9494
target_user = ""
95-
audience_context_id = (
96-
target_user + "\n" + target_group + "\n" + feature_flag_name + "\n" + group.get(FEATURE_FILTER_NAME_KEY, "")
97-
)
95+
audience_context_id = target_user + "\n" + feature_flag_name + "\n" + target_group
9896

9997
return self._is_targeted(audience_context_id, group_rollout_percentage)
10098

featuremanagement/_models/_feature_flag.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def convert_from_json(cls, json_value):
4141
if not isinstance(json_value, dict):
4242
raise ValueError("Feature flag must be a dictionary.")
4343
feature_flag._id = json_value.get(FEATURE_FLAG_ID)
44-
feature_flag._enabled = _convert_boolean_value(json_value.get(FEATURE_FLAG_ENABLED, True))
44+
feature_flag._enabled = _convert_boolean_value(json_value.get(FEATURE_FLAG_ENABLED, False))
4545
feature_flag._conditions = FeatureConditions.convert_from_json(
4646
feature_flag._id, json_value.get(FEATURE_FLAG_CONDITIONS, {})
4747
)
@@ -115,9 +115,9 @@ def variants(self):
115115

116116
def _validate(self):
117117
if not isinstance(self._id, str):
118-
raise ValueError("Feature flag id field must be a string.")
118+
raise ValueError(f"Invalid setting 'id' with value '{self._id}' for feature '{self._id}'.")
119119
if not isinstance(self._enabled, bool):
120-
raise ValueError(f"Feature flag {self._id} must be a boolean.")
120+
raise ValueError(f"Invalid setting 'enabled' with value '{self._enabled}' for feature '{self._id}'.")
121121
self.conditions._validate(self._id) # pylint: disable=protected-access
122122

123123

tests/all_feature_flag_options.json

Lines changed: 0 additions & 276 deletions
This file was deleted.

0 commit comments

Comments
 (0)