Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSSDK-9780] Return Latest Experiment When Duplicate Keys in Config #430

Merged
merged 7 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
linting
Mat001 committed Dec 5, 2023
commit f7b507b51687bcba1cabcdbf9c83b4b57d671405
2 changes: 1 addition & 1 deletion optimizely/optimizely_config.py
Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ def stringify_conditions(self, conditions: str | list[Any], audiences_map: dict[
operand = conditions[i].upper()
else:
# Check if element is a list or not
if type(conditions[i]) == list:
if isinstance(conditions[i], list):
# Check if at the end or not to determine where to add the operand
# Recursive call to call stringify on embedded list
if i + 1 < length:
72 changes: 36 additions & 36 deletions tests/test_optimizely_config.py
Original file line number Diff line number Diff line change
@@ -1479,45 +1479,45 @@ def test__duplicate_experiment_keys(self):

# update the test datafile with an additional feature flag with the same experiment rule key
new_experiment = {
'key': 'test_experiment', # added duplicate "test_experiment"
'status': 'Running',
'layerId': '8',
"audienceConditions": [
"or",
"11160"
],
'audienceIds': ['11160'],
'id': '111137',
'forcedVariations': {},
'trafficAllocation': [
{'entityId': '222242', 'endOfRange': 8000},
{'entityId': '', 'endOfRange': 10000}
],
'variations': [
{
'id': '222242',
'key': 'control',
'variables': [],
}
],
'key': 'test_experiment', # added duplicate "test_experiment"
'status': 'Running',
'layerId': '8',
"audienceConditions": [
"or",
"11160"
],
'audienceIds': ['11160'],
'id': '111137',
'forcedVariations': {},
'trafficAllocation': [
{'entityId': '222242', 'endOfRange': 8000},
{'entityId': '', 'endOfRange': 10000}
],
'variations': [
{
'id': '222242',
'key': 'control',
'variables': [],
}
],
}

new_feature = {
'id': '91117',
'key': 'new_feature',
'experimentIds': ['111137'],
'rolloutId': '',
'variables': [
{'id': '127', 'key': 'is_working', 'defaultValue': 'true', 'type': 'boolean'},
{'id': '128', 'key': 'environment', 'defaultValue': 'devel', 'type': 'string'},
{'id': '129', 'key': 'cost', 'defaultValue': '10.99', 'type': 'double'},
{'id': '130', 'key': 'count', 'defaultValue': '999', 'type': 'integer'},
{'id': '131', 'key': 'variable_without_usage', 'defaultValue': '45', 'type': 'integer'},
{'id': '132', 'key': 'object', 'defaultValue': '{"test": 12}', 'type': 'string',
'subType': 'json'},
{'id': '133', 'key': 'true_object', 'defaultValue': '{"true_test": 23.54}', 'type': 'json'},
],
}
'id': '91117',
'key': 'new_feature',
'experimentIds': ['111137'],
'rolloutId': '',
'variables': [
{'id': '127', 'key': 'is_working', 'defaultValue': 'true', 'type': 'boolean'},
{'id': '128', 'key': 'environment', 'defaultValue': 'devel', 'type': 'string'},
{'id': '129', 'key': 'cost', 'defaultValue': '10.99', 'type': 'double'},
{'id': '130', 'key': 'count', 'defaultValue': '999', 'type': 'integer'},
{'id': '131', 'key': 'variable_without_usage', 'defaultValue': '45', 'type': 'integer'},
{'id': '132', 'key': 'object', 'defaultValue': '{"test": 12}', 'type': 'string',
'subType': 'json'},
{'id': '133', 'key': 'true_object', 'defaultValue': '{"true_test": 23.54}', 'type': 'json'},
],
}

# add new experiment rule with the same key and a new feature with the same rule key
self.config_dict_with_features['experiments'].append(new_experiment)