pact-python icon indicating copy to clipboard operation
pact-python copied to clipboard

Pact broker support for the MessageProvider

Open selin194 opened this issue 4 years ago • 1 comments

As I understand, MessageProvider verifies pacts only for the given pacts directory .

Is there any way to achieve verification using pact-broker for the MessageProvider like using Verifier?

Thank you!

selin194 avatar Aug 10 '21 18:08 selin194

The verify method of the message provider is:

        pact_files = f'{self.pact_dir}/{self._pact_file()}'
        verifier = Verifier(provider=self.provider,
                            provider_base_url=self._proxy_url())
        return_code, _ = verifier.verify_pacts(pact_files, verbose=False)
        assert (return_code == 0), f'Expected returned_code = 0, actual = {return_code}'

Using that as guidance, I think that, as a workaround, you could create your own Verifier that checks pacts with a broker. Something like:

with provider:
    verifier = Verifier(provider='UserService', provider_base_url=provider._proxy_url())
    return_code, _ = verifier.verify_with_broker(**OPTIONS, verbose=False)
    assert (return_code == 0), f'Expected return_code = 0, actual = {return_code}'

taj-p avatar Aug 25 '21 10:08 taj-p

/cc @elliottmurray

I think this one can be closed, since it is solved in https://github.com/pact-foundation/pact-python/pull/257

sergeyklay avatar Mar 05 '23 08:03 sergeyklay

/cc @elliottmurray @matthewbalvanz-wf

sergeyklay avatar Mar 12 '23 22:03 sergeyklay