Skip to content

Commit

Permalink
🖊️ accommodate case where featureEnabled not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
oakbani committed Feb 19, 2018
1 parent f2d265a commit fb3f427
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion optimizely/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def __init__(self, id, value, **kwards):
self.id = id
self.value = value

def __init__(self, id, key, featureEnabled=False, variables=None, **kwargs):
def __init__(self, id, key, featureEnabled=None, variables=None, **kwargs):
if featureEnabled is None:
featureEnabled = False

self.id = id
self.key = key
self.featureEnabled = featureEnabled
Expand Down
19 changes: 19 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,25 @@ def test_init__with_v4_datafile(self):
self.assertEqual(expected_rollout_id_map, project_config.rollout_id_map)
self.assertEqual(expected_variation_variable_usage_map, project_config.variation_variable_usage_map)

def test_variation_has_featureEnabled_false_if_prop_undefined(self):
""" Test that featureEnabled property by default is set to False, when not given in the data file"""
variation = {
'key': 'group_exp_1_variation',
'id': '28902',
'variables': [{
'id': '128',
'value': 'stage'
}, {
'id': '129',
'value': '112'
}, {
'id': '130',
'value': '1.211'
}]}

variation_entity = entities.Variation(**variation)
self.assertFalse(variation_entity.featureEnabled)

def test_get_version(self):
""" Test that JSON version is retrieved correctly when using get_version. """

Expand Down

0 comments on commit fb3f427

Please sign in to comment.