From f6e48accc71a863998bf419edc16d7130d756307 Mon Sep 17 00:00:00 2001 From: Pawel Szczodruch Date: Tue, 21 Apr 2020 00:58:35 -0700 Subject: [PATCH] fix linters --- optimizely/optimizely.py | 4 ++-- tests/base.py | 6 ++++-- tests/test_config.py | 6 +++--- tests/test_optimizely.py | 15 ++++++++------- tests/test_optimizely_config.py | 18 +++++++++--------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/optimizely/optimizely.py b/optimizely/optimizely.py index 2f2f54ac..5bc0c9ac 100644 --- a/optimizely/optimizely.py +++ b/optimizely/optimizely.py @@ -339,7 +339,7 @@ def _get_all_feature_variables_for_type( ) all_variables = {} - for variable_key in feature_flag.variables: + for variable_key in feature_flag.variables: variable = project_config.get_variable_for_feature(feature_key, variable_key) variable_value = variable.defaultValue if feature_enabled: @@ -347,7 +347,7 @@ def _get_all_feature_variables_for_type( self.logger.info( 'Got variable value "%s" for variable "%s" of feature flag "%s".' % (variable_value, variable_key, feature_key) - ) + ) try: actual_value = project_config.get_typecast_value(variable_value, variable.type) diff --git a/tests/base.py b/tests/base.py index ba8923ec..204f72dd 100644 --- a/tests/base.py +++ b/tests/base.py @@ -328,7 +328,8 @@ def setUp(self, config_dict='config_dict'): {'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': '132', 'key': 'object', 'defaultValue': '{"test": 12}', 'type': 'string', + 'subType': 'json'}, ], }, { @@ -341,7 +342,8 @@ def setUp(self, config_dict='config_dict'): {'id': '133', 'key': 'message', 'defaultValue': 'Hello', 'type': 'string'}, {'id': '134', 'key': 'price', 'defaultValue': '99.99', 'type': 'double'}, {'id': '135', 'key': 'count', 'defaultValue': '999', 'type': 'integer'}, - {'id': '136', 'key': 'object', 'defaultValue': '{"field": 1}', 'type': 'string', 'subType': 'json'}, + {'id': '136', 'key': 'object', 'defaultValue': '{"field": 1}', 'type': 'string', + 'subType': 'json'}, ], }, { diff --git a/tests/test_config.py b/tests/test_config.py index 1cb635dd..13cf1105 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -284,7 +284,8 @@ def test_init__with_v4_datafile(self): {'id': '128', 'key': 'environment', 'defaultValue': 'devel', 'type': 'string'}, {'id': '129', 'key': 'number_of_days', 'defaultValue': '192', 'type': 'integer'}, {'id': '130', 'key': 'significance_value', 'defaultValue': '0.00098', 'type': 'double'}, - {'id': '131', 'key': 'object', 'defaultValue': '{"field": 12.4}', 'type': 'string', 'subType': 'json'}, + {'id': '131', 'key': 'object', 'defaultValue': '{"field": 12.4}', 'type': 'string', + 'subType': 'json'}, ], }, { @@ -898,8 +899,7 @@ def test_get_rollout_from_id__valid_rollout_id(self): }, ], ) - - print(json.loads(json.dumps(expected_rollout, default=lambda o: o.__dict__))) + self.assertEqual(expected_rollout, project_config.get_rollout_from_id('211111')) def test_get_rollout_from_id__invalid_rollout_id(self): diff --git a/tests/test_optimizely.py b/tests/test_optimizely.py index 787cc4e3..e1ab354c 100644 --- a/tests/test_optimizely.py +++ b/tests/test_optimizely.py @@ -2532,7 +2532,7 @@ def test_get_feature_variable_json(self): 'optimizely.notification_center.NotificationCenter.send_notifications' ) as mock_broadcast_decision: self.assertEqual( - {"test":123}, + {"test": 123}, opt_obj.get_feature_variable_json('test_feature_in_experiment', 'object', 'test_user'), ) @@ -2550,7 +2550,7 @@ def test_get_feature_variable_json(self): 'feature_enabled': True, 'source': 'feature-test', 'variable_key': 'object', - 'variable_value': {"test":123}, + 'variable_value': {"test": 123}, 'variable_type': 'json', 'source_info': {'experiment_key': 'test_experiment', 'variation_key': 'variation'}, }, @@ -2587,7 +2587,8 @@ def test_get_all_feature_variables(self): [ mock.call('Value for variable "count" for variation "variation" is "4243".'), mock.call('Value for variable "is_working" for variation "variation" is "true".'), - mock.call('Variable "variable_without_usage" is not used in variation "variation". Assigning default value "45".'), + mock.call('Variable "variable_without_usage" is not used in variation "variation". \ +Assigning default value "45".'), mock.call('Value for variable "object" for variation "variation" is "{"test": 123}".'), mock.call('Value for variable "environment" for variation "variation" is "staging".'), mock.call('Value for variable "cost" for variation "variation" is "10.02".') @@ -2740,7 +2741,7 @@ def test_get_feature_variable(self): 'optimizely.notification_center.NotificationCenter.send_notifications' ) as mock_broadcast_decision: self.assertEqual( - {"test":123}, opt_obj.get_feature_variable('test_feature_in_experiment', 'object', 'test_user'), + {"test": 123}, opt_obj.get_feature_variable('test_feature_in_experiment', 'object', 'test_user'), ) mock_config_logging.info.assert_called_once_with( @@ -2990,7 +2991,7 @@ def test_get_all_feature_variables_for_feature_in_rollout(self): self.assertEqual(5, mock_config_logging.info.call_count) mock_config_logging.info.assert_has_calls( - [ + [ mock.call('Value for variable "count" for variation "211129" is "399".'), mock.call('Value for variable "message" for variation "211129" is "Hello audience".'), mock.call('Value for variable "object" for variation "211129" is "{"field": 12}".'), @@ -3251,7 +3252,7 @@ def test_get_feature_variable__returns_default_value_if_variable_usage_not_in_va return_value=decision_service.Decision(mock_experiment, mock_variation, enums.DecisionSources.FEATURE_TEST), ), mock.patch.object(opt_obj.config_manager.get_config(), 'logger') as mock_config_logger: self.assertEqual( - {"test":12}, opt_obj.get_feature_variable_json('test_feature_in_experiment', 'object', 'test_user'), + {"test": 12}, opt_obj.get_feature_variable_json('test_feature_in_experiment', 'object', 'test_user'), ) mock_config_logger.info.assert_called_once_with( @@ -4085,7 +4086,7 @@ def test_get_feature_variable__returns_default_value_if_feature_not_enabled_in_r return_value=decision_service.Decision(mock_experiment, mock_variation, enums.DecisionSources.ROLLOUT), ), mock.patch.object(opt_obj, 'logger') as mock_client_logger: self.assertEqual( - {"field": 1}, opt_obj.get_feature_variable_json('test_feature_in_rollout', 'object', 'test_user'), + {"field": 1}, opt_obj.get_feature_variable_json('test_feature_in_rollout', 'object', 'test_user'), ) mock_client_logger.info.assert_called_once_with( 'Feature "test_feature_in_rollout" for variation "211229" is not enabled. ' diff --git a/tests/test_optimizely_config.py b/tests/test_optimizely_config.py index d6407aae..b284d4e5 100644 --- a/tests/test_optimizely_config.py +++ b/tests/test_optimizely_config.py @@ -255,11 +255,11 @@ def setUp(self): 'id': '129', 'value': '10.99' }, - 'object': { - 'id': '132', - 'key': 'object', - 'type': 'json', - 'value': '{"test": 12}' + 'object': { + 'id': '132', + 'key': 'object', + 'type': 'json', + 'value': '{"test": 12}' }, 'variable_without_usage': { 'key': 'variable_without_usage', @@ -299,10 +299,10 @@ def setUp(self): 'value': '10.02' }, 'object': { - 'id': '132', - 'key': 'object', - 'type': 'json', - 'value': '{"test": 123}' + 'id': '132', + 'key': 'object', + 'type': 'json', + 'value': '{"test": 123}' }, 'variable_without_usage': { 'key': 'variable_without_usage',