You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the provider verifies this contract, they will use this field to
setup pre-defined data that will satisfy the response expectations.
:param provider_state: The short sentence that is unique to describe
the provider state for this contract.
:type provider_state: basestring
:rtype: Pact
"""
self._insert_message_if_complete()
state= [{"name": "{}".format(provider_states)}]
self._messages[0]['providerStates'] =state
returnself
But often enough there is the need to define multiple provider states and also to be able to pass additional arguments to set the state (besides the provider state name).
To this end I put together this pull request: #322
This change allows multiple providers states to be defined and also additional parameters to be passed for each state, for example:
(
target
.given('there is an alligator named John',
params={'color':'green', 'weight_kg': 130, 'lenght_m': 1.95}
)
.given('there is an spider named Jack',
params={'color':'mostly black', 'weight_kg': 0.009, 'lenght_m': 0.05}
)
.expects_to_receive('an alligator message')
.with_content({'name': 'John', 'document_name': 'sample_document.doc'})
.with_metadata({'contentType': 'application/json',
'source': 'legacy_api',
'some-header': Term('\\d+-\\d+-\\d+T\\d+:\\d+:\\d+', '2022-02-15T20:16:01')})
)
It is also backwards compatible, in that it is possible to just pass a single state name.
The text was updated successfully, but these errors were encountered:
Currently for Message Pacts it is only possible to define a single provider state as a string.
Check the method that sets the state:
pact-python/pact/message_pact.py
Lines 101 to 117 in d87d54b
But often enough there is the need to define multiple provider states and also to be able to pass additional arguments to set the state (besides the provider state name).
To this end I put together this pull request: #322
This change allows multiple providers states to be defined and also additional parameters to be passed for each state, for example:
It is also backwards compatible, in that it is possible to just pass a single state name.
The text was updated successfully, but these errors were encountered: