Skip to content

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

Merged
merged 39 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ac7e81f
feat:semantic versioning
Jul 30, 2020
ee29674
semver updated
Jul 30, 2020
4a5e75d
more validation for invalid cases added
Aug 5, 2020
01ed4da
feat: Semantic Version
oakbani Aug 21, 2020
796af4d
GE and LE with test cases
Aug 24, 2020
f318995
Update test_condition.py
Aug 24, 2020
e016cd8
added ge le
msohailhussain Aug 24, 2020
857e8de
PR comments resolved
Aug 25, 2020
5f793a3
comments resolved
Aug 25, 2020
cfb12df
Update condition.py
Aug 25, 2020
379d637
Merge branch 'uzair/semver' into amna/semver
oakbani Aug 26, 2020
1c37fbf
invalid test case for semver and comment fixed
Aug 26, 2020
dcd391f
Update test_condition.py
Aug 26, 2020
2affb9d
Update test_condition.py
Aug 26, 2020
032d9c1
Merge branch 'uzair/semver' into amna/semver
oakbani Aug 26, 2020
8577f7c
compare implemetation and invalid testcase fixed
Aug 26, 2020
32bed45
Merge branch 'uzair/semver' into amna/semver
oakbani Aug 27, 2020
426d2b7
Revert "compare implemetation and invalid testcase fixed"
oakbani Aug 27, 2020
ac8113e
passes fsc at this point
oakbani Aug 27, 2020
84f6c26
fix:lint
oakbani Aug 27, 2020
ca7984a
remove: additional lint fixes
oakbani Aug 27, 2020
9256e6a
additional removal
oakbani Aug 27, 2020
15fa71b
further removal
oakbani Aug 27, 2020
8414a92
address most comments
oakbani Aug 28, 2020
78ce524
reorganize
oakbani Aug 28, 2020
aa1fbaf
tests: revised all unit tests
oakbani Aug 31, 2020
c8c0e75
Merge branch 'master' into amna/semver
oakbani Sep 2, 2020
907fcf2
address comments
oakbani Sep 2, 2020
8b4567c
add further checks
oakbani Sep 3, 2020
8856665
comments resolved
Sep 9, 2020
7ed20f0
comments resolved
Sep 9, 2020
4f2c05e
Update test_condition.py
Sep 14, 2020
4070805
Revert "Update test_condition.py"
Sep 14, 2020
4c471bd
Update test_condition.py
Sep 14, 2020
68708d9
Update test_condition.py
Sep 16, 2020
09533b1
Merge branch 'master' into amna/semver
msohailhussain Sep 16, 2020
ad17c02
testcase fixed
Sep 17, 2020
93cbb2a
Update condition.py
Sep 17, 2020
25ab44d
fix condition
oakbani Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
additional removal
  • Loading branch information
oakbani committed Aug 27, 2020
commit 9256e6a95d9106a94e18c201abda904a6788e30c
72 changes: 36 additions & 36 deletions optimizely/helpers/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def __init__(self, condition_data, attributes, logger):
def _get_condition_json(self, index):
""" Method to generate json for logging audience condition.

Args:
index: Index of the condition.
Args:
index: Index of the condition.

Returns:
String: Audience condition JSON.
"""
Returns:
String: Audience condition JSON.
"""
condition = self.condition_data[index]
condition_log = {
'name': condition[0],
Expand All @@ -74,12 +74,12 @@ def _get_condition_json(self, index):
def is_value_type_valid_for_exact_conditions(self, value):
""" Method to validate if the value is valid for exact match type evaluation.

Args:
value: Value to validate.
Args:
value: Value to validate.

Returns:
Boolean: True if value is a string, boolean, or number. Otherwise False.
"""
Returns:
Boolean: True if value is a string, boolean, or number. Otherwise False.
"""
# No need to check for bool since bool is a subclass of int
if isinstance(value, string_types) or isinstance(value, (numbers.Integral, float)):
return True
Expand Down Expand Up @@ -194,29 +194,29 @@ def compare_user_version_with_target_version(self, index):
def exact_evaluator(self, index):
""" Evaluate the given exact match condition for the user attributes.

Args:
index: Index of the condition to be evaluated.
Args:
index: Index of the condition to be evaluated.

Returns:
Boolean:
- True if the user attribute value is equal (===) to the condition value.
- False if the user attribute value is not equal (!==) to the condition value.
None:
- if the condition value or user attribute value has an invalid type.
- if there is a mismatch between the user attribute type and the condition value type.
"""
Returns:
Boolean:
- True if the user attribute value is equal (===) to the condition value.
- False if the user attribute value is not equal (!==) to the condition value.
None:
- if the condition value or user attribute value has an invalid type.
- if there is a mismatch between the user attribute type and the condition value type.
"""
condition_name = self.condition_data[index][0]
condition_value = self.condition_data[index][1]
user_value = self.attributes.get(condition_name)

if not self.is_value_type_valid_for_exact_conditions(condition_value) or (
self.is_value_a_number(condition_value) and not validator.is_finite_number(condition_value)
self.is_value_a_number(condition_value) and not validator.is_finite_number(condition_value)
):
self.logger.warning(audience_logs.UNKNOWN_CONDITION_VALUE.format(self._get_condition_json(index)))
return None

if not self.is_value_type_valid_for_exact_conditions(user_value) or not validator.are_values_same_type(
condition_value, user_value
condition_value, user_value
):
self.logger.warning(
audience_logs.UNEXPECTED_TYPE.format(self._get_condition_json(index), type(user_value), condition_name)
Expand All @@ -234,28 +234,28 @@ def exact_evaluator(self, index):
def exists_evaluator(self, index):
""" Evaluate the given exists match condition for the user attributes.

Args:
index: Index of the condition to be evaluated.
Args:
index: Index of the condition to be evaluated.

Returns:
Boolean: True if the user attributes have a non-null value for the given condition,
otherwise False.
"""
Returns:
Boolean: True if the user attributes have a non-null value for the given condition,
otherwise False.
"""
attr_name = self.condition_data[index][0]
return self.attributes.get(attr_name) is not None

def greater_than_evaluator(self, index):
""" Evaluate the given greater than match condition for the user attributes.

Args:
index: Index of the condition to be evaluated.
Args:
index: Index of the condition to be evaluated.

Returns:
Boolean:
- True if the user attribute value is greater than the condition value.
- False if the user attribute value is less than or equal to the condition value.
None: if the condition value isn't finite or the user attribute value isn't finite.
"""
Returns:
Boolean:
- True if the user attribute value is greater than the condition value.
- False if the user attribute value is less than or equal to the condition value.
None: if the condition value isn't finite or the user attribute value isn't finite.
"""
condition_name = self.condition_data[index][0]
condition_value = self.condition_data[index][1]
user_value = self.attributes.get(condition_name)
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers_tests/test_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def test_exact_int__returns_true__when_user_provided_value_is_equal_to_condition

self.assertStrictTrue(evaluator.evaluate(0))

def test_exact_float__returns_true__when_user_provided_value_is_equal_to_condition_value(self, ):
def test_exact_float__returns_true__when_user_provided_value_is_equal_to_condition_value(self,):

if PY2:
evaluator = condition_helper.CustomAttributeConditionEvaluator(
Expand Down Expand Up @@ -955,7 +955,7 @@ def test_less_than_int__returns_true__when_user_value_less_than_condition_value(

self.assertStrictTrue(evaluator.evaluate(0))

def test_less_than_float__returns_true__when_user_value_less_than_condition_value(self):
def test_less_than_float__returns_true__when_user_value_less_than_condition_value(self,):

evaluator = condition_helper.CustomAttributeConditionEvaluator(
lt_float_condition_list, {'meters_travelled': 48.1}, self.mock_client_logger
Expand Down