Skip to content

Commit

Permalink
fix test typos, add missing get_feature_var tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonhudavid committed Jul 24, 2019
1 parent 0b607b2 commit 0289c03
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions tests/test_optimizely.py
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,7 @@ def test_get_feature_variable_double_for_feature_in_rollout(self):
)

def test_get_feature_variable_integer_for_feature_in_rollout(self):
""" Test that get_feature_variable_double returns Double value as expected \
""" Test that get_feature_variable_integer returns Double value as expected \
and broadcasts decision with proper parameters. """

opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
Expand Down Expand Up @@ -2398,7 +2398,7 @@ def test_get_feature_variable_integer_for_feature_in_rollout(self):
)

def test_get_feature_variable_string_for_feature_in_rollout(self):
""" Test that get_feature_variable_double returns Double value as expected \
""" Test that get_feature_variable_string returns String value as expected \
and broadcasts decision with proper parameters. """

opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
Expand Down Expand Up @@ -2436,7 +2436,7 @@ def test_get_feature_variable_string_for_feature_in_rollout(self):
)

def test_get_feature_variable_for_feature_in_rollout(self):
""" Test that get_feature_variable returns Double value as expected \
""" Test that get_feature_variable returns value as expected \
and broadcasts decision with proper parameters. """

opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
Expand Down Expand Up @@ -3395,6 +3395,7 @@ def test_get_feature_variable__returns_none_if_unable_to_cast(self):
side_effect=ValueError()),\
mock.patch.object(opt_obj, 'logger') as mock_client_logger:
self.assertEqual(None, opt_obj.get_feature_variable_integer('test_feature_in_experiment', 'count', 'test_user'))
self.assertEqual(None, opt_obj.get_feature_variable('test_feature_in_experiment', 'count', 'test_user'))

mock_client_logger.error.assert_called_with('Unable to cast value. Returning None.')

Expand All @@ -3409,21 +3410,37 @@ def test_get_feature_variable_returns__variable_value__typed_audience_match(self
'xyz',
opt_obj.get_feature_variable_string('feat_with_var', 'x', 'user1', {'lasers': 71})
)
mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)

mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)
with mock.patch.object(opt_obj, 'logger') as mock_client_logger:
self.assertEqual(
'xyz',
opt_obj.get_feature_variable('feat_with_var', 'x', 'user1', {'lasers': 71})
)
mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)

# Should be included in the feature test via exact match boolean audience with id '3468206643'
with mock.patch.object(opt_obj, 'logger') as mock_client_logger:
self.assertEqual(
'xyz',
opt_obj.get_feature_variable_string('feat_with_var', 'x', 'user1', {'should_do_it': True})
)
mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)

mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)
with mock.patch.object(opt_obj, 'logger') as mock_client_logger:
self.assertEqual(
'xyz',
opt_obj.get_feature_variable('feat_with_var', 'x', 'user1', {'should_do_it': True})
)
mock_client_logger.info.assert_called_once_with(
'Got variable value "xyz" for variable "x" of feature flag "feat_with_var".'
)

""" Test that get_feature_variable_* return default value with typed audience mismatch. """
def test_get_feature_variable_returns__default_value__typed_audience_match(self):
Expand Down

0 comments on commit 0289c03

Please sign in to comment.