feat: Semantic Versioning#293
Conversation
|
Need to add FSC |
thomaszurkan-optimizely
left a comment
There was a problem hiding this comment.
LGTM, needs to pass FSC first.
thomaszurkan-optimizely
left a comment
There was a problem hiding this comment.
Actually we forgot le and ge (less than or equal and greater than or equal
optimizely/helpers/condition.py
Outdated
| def semver_equal_evaluator(self, index): | ||
| """ Evaluate the given semantic version equal match target version for the user version. | ||
|
|
||
| Args: |
There was a problem hiding this comment.
nit. Indentation is off. This needs to align with the quotes above.
|
|
||
| self.assertRaises(Exception) | ||
|
|
||
| def test_evalduate__returns_exception__when_user_provided_version_is_invalid9(self): |
There was a problem hiding this comment.
Typo in evaluate through the file
|
Taking a closer look at evaluation. But some typos as well as docstrings need to have aligned strings. |
optimizely/helpers/condition.py
Outdated
| if self.has_white_space(target): | ||
| raise Exception(Errors.INVALID_ATTRIBUTE_FORMAT) | ||
|
|
||
| if self.is_pre_release(target): | ||
| target_parts = target.split(SemverType.IS_PRE_RELEASE) | ||
| elif self.is_build(target): | ||
| target_parts = target.split(SemverType.IS_BUILD) | ||
|
|
||
| if target_parts: | ||
| if len(target_parts) < 1: | ||
| raise Exception(Errors.INVALID_ATTRIBUTE_FORMAT) | ||
| target_prefix = str(target_parts[0]) | ||
| target_suffix = target_parts[1:] | ||
|
|
||
| dot_count = target_prefix.count(".") | ||
| if dot_count > 2: | ||
| raise Exception(Errors.INVALID_ATTRIBUTE_FORMAT) |
There was a problem hiding this comment.
Can you add comments over each of these about what is being checked in the if condition?
| IS_PRE_RELEASE = '-' | ||
| HAS_WHITE_SPACE = " " | ||
| IS_BUILD = '+' |
There was a problem hiding this comment.
We should use single quotes for all strings.
| self.assertIsNone(evaluator.evaluate(0)) | ||
|
|
||
| def test_greater_than_int__returns_true__when_user_value_greater_than_condition_value(self,): | ||
| def test_greater_than_int__returns_true__when_user_value_greater_than_condition_value(self, ): |
There was a problem hiding this comment.
Why the , and this can simply be (self) right?
Summary
This PR adds support for semantic versioning in audience evaluation.
Test plan
Added unit tests