Search code examples
pythonpactpactflow

Provider side verification in Pact


Trying out pactflow with python. My consumer tests get published correctly, now for the verification side. Provider verification works as expected if I do this, with publish set to false:


# Define the provider and consumer names
PROVIDER_NAME = 'BackendService'
CONSUMER_NAME = 'FrontendApp'

# Create a new Verifier instance
verifier = Verifier(provider=PROVIDER_NAME, provider_base_url="http://127.0.0.1:8080")

# Configure the Verifier to use Pactflow as the broker
default_opts = {
    'pact_url': 'https://my_url.pactflow.io/pacts/provider/BackendService/consumer/FrontendApp/version/1.0.0',
    'broker_url': 'https://my_url.pactflow.io',
    'broker_token': 'my token',
    'publish_verification_results': False,
    'publish-version':'1.0.0',
    'provider_app_version': '1.0.0',
'consumer_app_version': '1.0.0'}
output, logs = verifier.verify_with_broker(**default_opts)
print(output)

When I try to set publish_verification_results to True, to see the results reflected in pactflow, I see: venv/lib/python3.10/site-packages/pact/bin/pact/lib/vendor/ruby/3.2.0/gems/pact-1.63.0/lib/pact/provider/configuration/service_provider_dsl.rb:88:in `validate': Please set the app_version when publish_verification_results is true (Pact::Provider::Configuration::Error)


Solution

  • I think you meant to pass through publish_version (underscore)

    See https://github.com/pact-foundation/pact-python/blob/093d9b85c0c6bfc81be60e990e6c17ca103977fc/pact/verifier.py#L104C11-L104C11