-
Notifications
You must be signed in to change notification settings - Fork 137
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: Support pending Pacts #171
Conversation
4f35751
to
b2828ab
Compare
To conform to contributing guideline. Closes pact-foundation#151.
Most probably rebasing artifact.
915e278
to
80e90f6
Compare
@m-aciek |
@matthewbalvanz-wf Unfortunately in 3.4 and 3.5 mock that is shipped with unittest has different API than in 3.8 so the asserts in VerifyWrapper tests fail. |
e256b9d
to
a344f3d
Compare
pact/cli/verify.py
Outdated
@click.option( | ||
'log_dir', '--log-dir', | ||
help='The directory for the pact.log file.') | ||
@click.option( | ||
'log_level', '--log-level', | ||
help='The logging level.') | ||
@click.option( | ||
'enable_pending', '--enable-pending/--no-enable-pending', |
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.
How about 'pending', '--pending/--no-pending',default=False
is_flag=True will be passed implicitly if a boolean flag is used.
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 wanted to replicate the flag that is used in underlying CLI and to be in line with flag name used in documentation https://docs.pact.io/pact_broker/advanced_topics/pending_pacts/#to-start-using-the-pending-pacts-feature.
I used default=None also to replicate usage of underlying CLI so to map False -> --enable…, True -> --no-enable…, None -> no flag.
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 right. It is said to use
enable-pending
convention: Master issue for new 'pending pacts' feature pact_broker#320 - it is also said that flag should be set to False as a default value. Moreover I do not see a case when
no flag
differs fromno-enable-pending
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.
Ok, so to be in line with the guidelines you linked and to make the implementation minimal, I will stick only with positive flag, set False as default and do not add --no-enable-pending to underlying library.
pact/verify_wrapper.py
Outdated
@@ -199,3 +200,11 @@ def publish_results(self, provider_app_version, command): | |||
command.extend(["--provider-app-version", | |||
provider_app_version, | |||
"--publish-verification-results"]) | |||
|
|||
@classmethod | |||
def _get_enable_pending_flag(cls, flag_value): |
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.
How about
def _get_boolean_flag(self, flags, flag_name):
flag_value = flags.get(flag_name)
if flag_value is True:
return ['--' + flag_name]
elif flag_value is False:
return ['--no-' + flag_name]
return []
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.
There is no such a flag as --no-verbose, and for just one case I think it is a premature optimisation.
pact/verify_wrapper.py
Outdated
@@ -169,6 +169,7 @@ def call_verify(self, *pacts, provider_base_url, provider, **kwargs): | |||
|
|||
if(kwargs.get('verbose', False) is True): | |||
command.extend(['--verbose']) | |||
command.extend(self._get_enable_pending_flag(kwargs.get('enable_pending'))) |
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.
_get_boolean_flag('pending')
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.
There is no such a flag as --no-verbose, and for just one case I think it is a premature optimisation.
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.
Maybe I am wrong, but I think there is a no-verbose
flag.
https://github.com/pact-foundation/pact-python/pull/171/files#diff-99dbf564da4f139a45a61bf9c28b4f28R104
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.
It is lacking in the ruby verifier help message (see https://github.com/pact-foundation/pact-provider-verifier/blob/master/README.md), but I checked and indeed this ruby binary accepts --no-verbose. Although according to #171 (comment) I'll drop the negative flag passing.
@@ -169,6 +169,7 @@ def call_verify(self, *pacts, provider_base_url, provider, **kwargs): | |||
|
|||
if(kwargs.get('verbose', False) is True): |
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.
command.extend(self. _get_boolean_flag('verbose'))
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.
There is no such a flag as --no-verbose, and for just one case I think it is a premature optimisation.
@matthewbalvanz-wf Summary of failing tests because of mock in 3.5 compatibility issues:
|
Looks like |
pact/verify_wrapper.py
Outdated
@@ -169,6 +169,7 @@ def call_verify(self, *pacts, provider_base_url, provider, **kwargs): | |||
|
|||
if(kwargs.get('verbose', False) is True): | |||
command.extend(['--verbose']) | |||
command.extend(self._get_enable_pending_flag(kwargs.get('enable_pending'))) |
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.
Maybe I am wrong, but I think there is a no-verbose
flag.
https://github.com/pact-foundation/pact-python/pull/171/files#diff-99dbf564da4f139a45a61bf9c28b4f28R104
pact/cli/verify.py
Outdated
@click.option( | ||
'log_dir', '--log-dir', | ||
help='The directory for the pact.log file.') | ||
@click.option( | ||
'log_level', '--log-level', | ||
help='The logging level.') | ||
@click.option( | ||
'enable_pending', '--enable-pending/--no-enable-pending', |
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 right. It is said to use
enable-pending
convention: Master issue for new 'pending pacts' feature pact_broker#320 - it is also said that flag should be set to False as a default value. Moreover I do not see a case when
no flag
differs fromno-enable-pending
a344f3d
to
b444924
Compare
8247424
to
dddc746
Compare
I've added Python 3.4 syntax compatibility and simplified code. Ready for review again. |
dddc746
to
e840587
Compare
I've fixed code issue with Click option. |
Would you mind leaving it as --enable-pending and --no-enable-pending in the python interface? When trying to write documentation that is applicable for all languages, it makes it very difficult when each of the 11 languages chooses a slightly different option name! |
@bethesque isn't the 'no' option redundant? Just wondering if it should be default off and you just ask --enable-pending but not sure what the plans are for this ongoing? |
@bethesque @elliottmurray I had the same doubt and simplified implementation to avoid redundancy. The use case for --no-enable-pending that I can think of would be having some default configuration (e.g. in pyproject.toml) that could be overridden in a command call. I plan to implement support for --no-enable-pending on another branch and open new alternative pull request to avoid going round in circles in case of further discussion. |
In this use case default for enable-pending flag would be |
I'm going to merge this and do a release later. It doesn't harm as far as I can tell and we can add the extra flag in another PR |
Sorry, I don't care about --no-enable-pending, just the --enable-pending (rather than --pending or whatever it was) |
Closes #164.