-
Notifications
You must be signed in to change notification settings - Fork 0
latest fix #2
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
base: amna/semver
Are you sure you want to change the base?
latest fix #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix lint issues and address comments
optimizely/helpers/condition.py
Outdated
self._get_condition_json(0), type(user_version), user_version | ||
) | ||
) | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to put this here because
- We have already verified these in all evaluators that call this method.
- This method doesn't have attribute name and index to log the error.
@@ -29,14 +29,18 @@ | |||
semver_equal_2_0_condition_list = [['Android', "2.0", 'custom_attribute', 'semver_eq']] | |||
semver_equal_2_0_1_beta_condition_list = [['Android', "2.0.1-beta", 'custom_attribute', 'semver_eq']] | |||
semver_greater_than_2_0_0_condition_list = [['Android', "2.0.0", 'custom_attribute', 'semver_gt']] | |||
semver_greater_than_2_0_condition_list = [['Android', "2.0", 'custom_attribute', 'semver_gt']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all semver conditions from here. Instead declare it as a local variable inside it's respective method.
semver_equal_2_0_condition_list, {'Android': user_version}, self.mock_client_logger) | ||
result = evaluator.evaluate(0) | ||
custom_err_msg = "Got {} in result. Failed for user version: {}".format(result, user_version) | ||
self.assertEquals(result, True, custom_err_msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. Use assertTrue or assertStrictTrue instead
|
||
def test_evaluate__returns_exception__when_user_provided_version_is_invalid7(self): | ||
def test_evaluate__returns_false__when_user_version_matches_target_version(self): | ||
user_versions = ['2.9', '1.9'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. does not match
condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': "3.90"}, self.mock_client_logger | ||
) | ||
def test_evaluate__returns_true__when_user_version_less_than_or_equal_to_target_version(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename all tests to something that shows the exact evaluator being used.
test_semver_eq__returns _true
test_semver_gt__returns_false
('2', '2.12'), | ||
('2', '2.785.13') | ||
] | ||
for user_version, target_version in versions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_version should come before user_version. Even compare method accepts target_version as first arg. This is mis leading.
Keep target before user in list, in iteration and passing arg
@@ -431,23 +363,23 @@ def test_exists__returns_true__when_user_provided_value_is_boolean(self): | |||
|
|||
self.assertStrictTrue(evaluator.evaluate(0)) | |||
|
|||
def test_exact_string__returns_true__when_user_provided_value_is_equal_to_condition_value(self,): | |||
def test_exact_string__returns_true__when_user_provided_value_is_equal_to_condition_value(self, ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all these fixes below from the diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few more changes
@@ -25,22 +25,16 @@ | |||
doubleCondition = ['pi_value', 3.14, 'custom_attribute', 'exact'] | |||
|
|||
semver_equal_2_0_0_condition_list = [['Android', "2.0.0", 'custom_attribute', 'semver_eq']] | |||
semver_equal_2_condition_list = [['Android', "2", 'custom_attribute', 'semver_eq']] | |||
semver_equal_2_0_condition_list = [['Android', "2.0", 'custom_attribute', 'semver_eq']] | |||
semver_equal_2_0_1_beta_condition_list = [['Android', "2.0.1-beta", 'custom_attribute', 'semver_eq']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see other variables starting with prefix semver_ here. Are they being used? If not, we should remove them.
] | ||
for user_version, target_version in versions: | ||
for target_version, user_version in versions: | ||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_2_0_condition_list, {'Android': user_version}, self.mock_client_logger) | ||
result = evaluator.compare_user_version_with_target_version(user_version, target_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are still passing in the wrong order
] | ||
for user_version, target_version in versions: | ||
for target_version, user_version in versions: | ||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_2_0_condition_list, {'Android': user_version}, self.mock_client_logger) | ||
result = evaluator.compare_user_version_with_target_version(user_version, target_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and below as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
@@ -184,7 +172,7 @@ def test_evaluate__returns_false__when_user_version_greater_than_or_equal_to_tar | |||
custom_err_msg = "Got {} in result. Failed for user version: {}".format(result, user_version) | |||
self.assertFalse(result, custom_err_msg) | |||
|
|||
def test_evaluate__returns_true__when_user_version_less_than_target_version(self): | |||
def test_semver_le__returns_true(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. lt
@@ -194,7 +182,7 @@ def test_evaluate__returns_true__when_user_version_less_than_target_version(self | |||
custom_err_msg = "Got {} in result. Failed for user version: {}".format(result, user_version) | |||
self.assertTrue(result, custom_err_msg) | |||
|
|||
def test_evaluate__returns_false__when_user_version_less_than_target_version(self): | |||
def test_semver_le__returns_false(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. lt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix test failures and lint fixes. And we should be good to go
…into uzair/semver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix this
optimizely/helpers/condition.py
Outdated
return True | ||
else: | ||
return False | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove both elses. And just use return False in the end.
optimizely/helpers/condition.py
Outdated
return True | ||
else: | ||
return False | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Summary