-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Semantic Versioning #293
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
Changes from 1 commit
ac7e81f
ee29674
4a5e75d
01ed4da
796af4d
f318995
e016cd8
857e8de
5f793a3
cfb12df
379d637
1c37fbf
dcd391f
2affb9d
032d9c1
8577f7c
32bed45
426d2b7
ac8113e
84f6c26
ca7984a
9256e6a
15fa71b
8414a92
78ce524
aa1fbaf
c8c0e75
907fcf2
8b4567c
8856665
7ed20f0
4f2c05e
4070805
4c471bd
68708d9
09533b1
ad17c02
93cbb2a
25ab44d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2016-2019, Optimizely | ||
# Copyright 2016-2020, Optimizely | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
@@ -122,165 +122,162 @@ def test_evaluate__returns_null__when_condition_has_an_invalid_type_property(sel | |
|
||
self.assertIsNone(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_matches_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_matches_target_version_2(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': '2.0'}, self.mock_client_logger | ||
semver_equal_2_condition_list, {'Android': '2'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_0_condition_list, {'Android': '2.0.0'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
def test_evaluate__returns_true__when_user_version_2_2_matches_target_version_2(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_1_beta_condition_list, {'Android': '2.0.1-beta'}, self.mock_client_logger | ||
semver_equal_2_condition_list, {'Android': '2.2'}, self.mock_client_logger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this set true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comparison is made upto the len of target version. The target version is set to 2 here. @thomaszurkan-optimizely |
||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_0_condition_list, {'Android': '2.0.0.123'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
def test_evaluate__returns_true__when_user_version_2_0_matches_target_version_2_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_condition_list, {'Android': '2.123'}, self.mock_client_logger | ||
semver_equal_2_0_condition_list, {'Android': '2.0'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_does_not_match_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_0_0_matches_target_version_2_0_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': '1.0'}, self.mock_client_logger | ||
semver_equal_2_0_0_condition_list, {'Android': '2.0.0'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictFalse(evaluator.evaluate(0)) | ||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_2_0_does_not_match_target_version_2_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_0_condition_list, {'Android': '2.0'}, self.mock_client_logger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this false? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reason as above. The target version has been defined to higher precision 2.0.0. And the user version is only 2.0 |
||
) | ||
|
||
self.assertStrictFalse(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_is_greater_than_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_0_0_release_is_greater_than_target_version_2_0_0_beta( | ||
self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_2_0_0_beta_condition_list, {'Android': '2.0.0-release'}, self.mock_client_logger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is greater because release > beta? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_2_0_0_condition_list, {'Android': '2.0.1-release'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_is_not_greater_than_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_0_1_is_greater_than_target_version__2_0_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_2_0_0_condition_list, {'Android': '1.1.1'}, self.mock_client_logger | ||
semver_greater_than_2_0_0_condition_list, {'Android': '2.0.1'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictFalse(evaluator.evaluate(0)) | ||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_is_less_than_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_1_9_9_is_less_than_target_version_2_0_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_condition_list, {'Android': '1.9.1'}, self.mock_client_logger | ||
semver_less_than_2_0_0_condition_list, {'Android': '1.9.9'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_1_9_0_beta_is_less_than_target_version_2_0_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_condition_list, {'Android': '1.9.0-beta'}, self.mock_client_logger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will get better to compare 2.0.0-beta against 2.0.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this test different from test_evaluate__returns_true__when_user_version_2_0_0_beta_is_less_than_target_version_2_0_0_release ? We are not learning anything new. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, removed this one. The other that you mentioned should suffice. |
||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_release_condition_list, {'Android': '2.0.0-beta'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
def test_evaluate__returns_true__when_user_version_2_0_0_release_is_less_than_target_version_2_0_0(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_condition_list, {'Android': '2.0.0-beta'}, self.mock_client_logger | ||
semver_less_than_2_0_0_condition_list, {'Android': '2.0.0-release'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_2_0_0_beta_is_less_than_target_version_2_0_0_release(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_condition_list, {'Android': '2.0.0-release'}, self.mock_client_logger | ||
semver_less_than_2_0_0_release_condition_list, {'Android': '2.0.0-beta'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_is_not_less_than_target_version(self): | ||
def test_evaluate__returns_false__when_user_version_2_0_0_release_is_not_less_than_target_version_2_0_0_beta(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_2_0_0_beta_condition_list, {'Android': '2.0.0-release'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictFalse(evaluator.evaluate(0)) | ||
|
||
|
||
|
||
def test_evaluate__returns_true__when_user_version_is_greater_than_or_equal_to_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_0_9_is_greater_than_or_equal_to_target_version_2_0_9(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_or_equal_2_0_9_condition_list, {'Android': '2.0.9'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_2_3_is_greater_than_or_equal_to_target_version_2_0_9(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_or_equal_2_0_9_condition_list, {'Android': '2.3'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_2_0_9_beta_is_greater_than_or_equal_to_target_version_2_0_9_beta( | ||
self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_or_equal_2_0_9_beta_condition_list, {'Android': '2.0.9-beta'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_is_not_greater_than_or_equal_to_target_version(self): | ||
def test_evaluate__returns_false__when_user_version_1_0_0_is_not_greater_than_or_equal_to_target_version_2_0_9( | ||
self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_greater_than_or_equal_2_0_9_condition_list, {'Android': '1.0.0'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictFalse(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_is_less_than_or_equal_to_target_version(self): | ||
def test_evaluate__returns_true__when_user_version_2_0_1_is_less_than_or_equal_to_target_version_2_0_1(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_or_equal_2_0_1_condition_list, {'Android': '2.0.1'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_1_1_is_less_than_or_equal_to_target_version_2_0_1(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_or_equal_2_0_1_condition_list, {'Android': '1.1'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_true__when_user_version_2_0_1_beta_is_less_than_or_equal_to_target_version_2_0_1(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_or_equal_2_0_1_beta_condition_list, {'Android': '2.0.1-beta'}, self.mock_client_logger | ||
semver_less_than_or_equal_2_0_1_condition_list, {'Android': '2.0.1-beta'}, self.mock_client_logger | ||
) | ||
|
||
self.assertStrictTrue(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_false__when_user_version_is_not_less_than_or_equal_to_target_version(self): | ||
def test_evaluate__returns_false__when_user_version_3_0_1_is_not_less_than_or_equal_to_target_version_2_0_1(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
semver_less_than_or_equal_2_0_1_condition_list, {'Android': '3.0.1'}, self.mock_client_logger | ||
|
@@ -304,27 +301,33 @@ def test_evaluate__returns_null__when_user_provided_version_is_null(self): | |
|
||
self.assertIsNone(evaluator.evaluate(0)) | ||
|
||
def test_evaluate__returns_null__when_user_provided_version_is_invalid(self): | ||
def test_evaluate__returns_exception__when_user_provided_version_is_invalid1(self): | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': "+"}, self.mock_client_logger | ||
) | ||
|
||
self.assertRaises(Exception) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
def test_evalduate__returns_exception__when_user_provided_version_is_invalid2(self): | ||
|
||
condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': "+--"}, self.mock_client_logger | ||
) | ||
|
||
self.assertRaises(Exception) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
def test_evalduate__returns_exception__when_user_provided_version_is_invalid3(self): | ||
|
||
condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': "...+"}, self.mock_client_logger | ||
) | ||
|
||
self.assertRaises(Exception) | ||
|
||
evaluator = condition_helper.CustomAttributeConditionEvaluator( | ||
def test_evalduate__returns_exception__when_user_provided_version_is_invalid4(self): | ||
|
||
condition_helper.CustomAttributeConditionEvaluator( | ||
semver_equal_2_0_condition_list, {'Android': "+test"}, self.mock_client_logger | ||
) | ||
|
||
|
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. Indentation is off. This needs to align with the quotes above.