Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = E226,E302,E41,W503
max-line-length = 160
max-complexity = 10
max-complexity = 15
Copy link
Member

Choose a reason for hiding this comment

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

😆 did this tip us over the edge?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tested this but in terms of adding a param to the ruby engine this seems legit. I can test early next week and get a release done. To Matt's point do we know why it has bumped to 15? Quite a jump. Assume it's the extra param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the extra parameter breaks complexity rules, same in #300

Copy link
Member

Choose a reason for hiding this comment

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

we can drop it to 12

./pact/verify_wrapper.py:136:5: C901 'VerifyWrapper.call_verify' is too complex (11)
./pact/broker.py:51:5: C901 'Broker.publish' is too complex (12)

exclude = .git,venv,.venv,.tox,.pytest_cache,.direnv
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ May be specified multiple times. Read more about selectors [here](https://docs.p

Tag to apply to the provider application version. May be specified multiple times.

###### --provider-version-branch

Branch to apply to the provider application version.

###### --custom-provider-header

Header to add to provider state set up and pact verification requests e.g.`Authorization: Basic cGFjdDpwYWN0`
Expand Down
7 changes: 6 additions & 1 deletion pact/cli/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
multiple=True,
help='Tag to apply to the provider application version. '
'May be specified multiple times.')
@click.option(
'provider_version_branch', '--provider-version-branch',
default='',
help='The name of the branch the provider version belongs to.')
@click.option(
'password', '--pact-broker-password',
envvar='PACT_BROKER_PASSWORD',
Expand Down Expand Up @@ -125,7 +129,7 @@ def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
username, broker_base_url, consumer_version_tag, consumer_version_selector,
provider_version_tag, password, token, provider, headers, timeout,
provider_app_version, publish_verification_results, verbose, log_dir,
log_level, enable_pending, include_wip_pacts_since):
log_level, enable_pending, include_wip_pacts_since, provider_version_branch):
"""
Verify one or more contracts against a provider service.

Expand Down Expand Up @@ -181,6 +185,7 @@ def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
'consumer_tags': list(consumer_version_tag),
'consumer_selectors': list(consumer_version_selector),
'provider_tags': list(provider_version_tag),
'provider_version_branch': provider_version_branch,
'provider_states_setup_url': states_setup_url,
}

Expand Down
4 changes: 3 additions & 1 deletion pact/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def extract_params(self, **kwargs):
publish_verification_results = kwargs.get('publish_verification_results', None)
raw_consumer_selectors = kwargs.get('consumer_version_selectors', [])
consumer_selectors = self._build_consumer_selectors(raw_consumer_selectors)
provider_version_branch = kwargs.get('provider_version_branch')

options = {
'log_dir': log_dir,
Expand All @@ -121,7 +122,8 @@ def extract_params(self, **kwargs):
'verbose': verbose,
'provider_app_version': provider_app_version,
'consumer_selectors': consumer_selectors,
'publish_verification_results': publish_verification_results
'publish_verification_results': publish_verification_results,
'provider_version_branch': provider_version_branch
}
return self.filter_empty_options(**options)

Expand Down
4 changes: 4 additions & 0 deletions pact/verify_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def call_verify(
self._validate_input(pacts, **kwargs)

provider_app_version = kwargs.get('provider_app_version')
provider_version_branch = kwargs.get('provider_version_branch')
options = {
'--provider-base-url': provider_base_url,
'--provider': provider,
Expand Down Expand Up @@ -180,6 +181,9 @@ def call_verify(
if include_wip_pacts_since:
command.extend(['--include-wip-pacts-since={}'.format(include_wip_pacts_since)])

if provider_version_branch:
command.extend(["--provider-version-branch={}".format(provider_version_branch)])

headers = kwargs.get('custom_provider_headers', [])
for header in headers:
command.extend(['{}={}'.format('--custom-provider-header', header)])
Expand Down
4 changes: 3 additions & 1 deletion tests/cli/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def test_all_broker_options(self, mock_wrapper):
'--verbose',
'--enable-pending',
'--include-wip-pacts-since=2018-01-01',
'--provider-version-branch=provider-branch'
])

self.assertEqual(result.exit_code, 0, result.output)
Expand All @@ -315,7 +316,8 @@ def test_all_broker_options(self, mock_wrapper):
timeout=60,
verbose=True,
enable_pending=True,
include_wip_pacts_since='2018-01-01')
include_wip_pacts_since='2018-01-01',
provider_version_branch='provider-branch')

@patch("pact.verify_wrapper.isfile", return_value=True)
def test_publishing_missing_version(self, mock_isfile):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_verify_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def setUp(self):
'--consumer-version-tag=dev',
'--no-enable-pending',
'--provider-version-tag=dev',
'--provider-version-tag=qa']
'--provider-version-tag=qa',
'--provider-version-branch=provider-branch']

def assertProcess(self, *expected):
self.assertEqual(self.mock_Popen.call_count, 1)
Expand Down Expand Up @@ -154,7 +155,8 @@ def test_uses_broker_if_no_pacts_and_provider_required(self):
broker_token='token',
broker_url='http://broker',
consumer_tags=['prod', 'dev'],
provider_tags=['dev', 'qa'])
provider_tags=['dev', 'qa'],
provider_version_branch='provider-branch')

self.assertProcess(*self.broker_call)
self.assertEqual(result, 0)
Expand Down