Skip to content
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

feat: Semantic Versioning #293

Merged
merged 39 commits into from
Sep 17, 2020

Conversation

AmnaEjaz
Copy link
Contributor

@AmnaEjaz AmnaEjaz commented Jul 30, 2020

Summary

This PR adds support for semantic versioning in audience evaluation.

Test plan

Added unit tests

@msohailhussain
Copy link
Contributor

Need to add FSC

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, needs to pass FSC first.

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we forgot le and ge (less than or equal and greater than or equal

def semver_equal_evaluator(self, index):
""" Evaluate the given semantic version equal match target version for the user version.

Args:
Copy link
Contributor

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.


self.assertRaises(Exception)

def test_evalduate__returns_exception__when_user_provided_version_is_invalid9(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in evaluate through the file

@aliabbasrizvi
Copy link
Contributor

Taking a closer look at evaluation. But some typos as well as docstrings need to have aligned strings.

Comment on lines 333 to 349
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments over each of these about what is being checked in the if condition?

optimizely/helpers/condition.py Outdated Show resolved Hide resolved
Comment on lines 163 to 165
IS_PRE_RELEASE = '-'
HAS_WHITE_SPACE = " "
IS_BUILD = '+'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use single quotes for all strings.

@@ -379,7 +586,7 @@ def test_substring__returns_null__when_no_user_provided_value(self):

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, ):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the , and this can simply be (self) right?

@yasirfolio3 yasirfolio3 reopened this Sep 17, 2020
Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit c78e3de into optimizely:master Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants