Elliott Murray
09/11/2022, 10:54 AMElliott Murray
09/11/2022, 10:55 AMMaurice Mretens
09/21/2022, 6:49 PMevent = {
"event": "delivery:created",
"delivery_type": matchers.Term("express|standard", "standard"),
}
(
pact_no_publish.given("Delivery has standard shipping")
.expects_to_receive("delivery:created")
.with_content(event)
.with_metadata({"Content-Type": "application/json"})
)
What this does is to pass the Term object into the message.
What I have to do in this case is this:
event = {
"event": "delivery:created",
"delivery_type": matchers.Term("express|standard", "standard").generate()["data"]["generate"],
}
Is this the intended way or should it be done im some other way?Tatiana
10/04/2022, 5:25 PMfrom fastapi import APIRouter
from pydantic import BaseModel
from eventhub.core.events.types import EventLifecycle, EventStatus
from tests.e2e.conftest import team_factory, event_factory
pact_router = APIRouter()
STARTED_EVENT_ID = "ba5ec002-6fac-4285-bbbb-46c8801fb283"
TEAM_ID = "dummy_tid"
class ProviderState(BaseModel):
state: str # noqa: E999
@pact_router.post("/_pact/provider_states")
async def provider_states(provider_state: ProviderState):
mapping = {
"I can get a specific event": setup_started_event
}
mapping[provider_state.state]()
return {"result": mapping[provider_state.state]}
async def setup_started_event(db_session):
await team_factory(db_session, team_id=TEAM_ID)
await event_factory(
db_session, STARTED_EVENT_ID, team_id=TEAM_ID, life_cycle=EventLifecycle.STARTED, status=EventStatus.PUBLISHED
)
The application is running and I am trying to verify my pact by running:
pact-verifier --provider-base-url=<http://localhost:8000> --pact-url=./pacts/mousedeer-events-consumer-eventhub-provider.json --provider-states-setup-url=<http://localhost:8000/_pact/provider_states>
But I am getting the errors:
Failures:
1) Verifying a pact between mousedeer-events-consumer and eventhub-provider Given I can get a specific event a request to get a specific event with GET /events/ba5ec002-6fac-4285-bbbb-46c8801fb283 returns a response which has status code 200
Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer]
Pact::ProviderVerifier::SetUpProviderStateError:
Error setting up provider state 'I can get a specific event' for consumer 'mousedeer-events-consumer' at <http://localhost:8000/_pact/provider_states>. response status=404 response body={"detail":"Not Found"}
...
...
...
6) Verifying a pact between mousedeer-events-consumer and eventhub-provider Given I can get all events a request to get all events with GET /events?limit=10&name=&offset=0 returns a response which includes headers "Content-Type" which equals "application/json"
Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer]
Pact::ProviderVerifier::SetUpProviderStateError:
Error setting up provider state 'I can get all events' for consumer 'mousedeer-events-consumer' at <http://localhost:8000/_pact/provider_states>. response status=404 response body={"detail":"Not Found"}
First, I am wondering why it tries to setup a state for my all two endpoints if I provided state just for one?
Second, does this setup looks fine or something is wrong? Unfortunately, I don’t fully understand how post request should be implemented for pact states (as I can see it should be done according to this), so I just tried to use your example.
Third, do I understand correctly that in my case I should seed my local DB (the app and DB is running against localhost in my case)? or I can use fakedb as in your example?Jayesh Guru
10/14/2022, 7:56 PMfrom pact import Verifier
PACT_BROKER_URL = "<http://pactbroker.service.xxx.xxx.xxx.com/>"
# I am spinning up our provider service(my-service) in docker-compose on 5002 port
PROVIDER_HOST = "my-service"
PROVIDER_PORT = 5002
PROVIDER_URL = f"http://{PROVIDER_HOST}:{PROVIDER_PORT}"
@pytest.fixture
def broker_opts():
return {
"broker_url": PACT_BROKER_URL,
"publish_version": "3",
"publish_verification_results": False,
}
def test_service_provider_against_broker(broker_opts):
headers=["Authorization: Bearer my_jwt_token"]
headers.append("Content-Type:application/json")
verifier = Verifier(provider="my_provider_python_service", provider_base_url=PROVIDER_URL)
success, logs = verifier.verify_with_broker(
**broker_opts,
verbose=True,
provider_states_setup_url=f"{PROVIDER_URL}/my_path",
enable_pending=False,
headers=headers
)
assert success == 0
Orhun Vatansever
10/18/2022, 7:51 PMpact-jvm-consumer-java8_2.12
, and the python one using pact-foundation package. I can see the pacts published on my broker, and when I want to verify my producer contract in python, I get an error called "no matched handler". I saw some github discussions about message queue contracts being v3 and python having ruby implementation which supports v2, could this error be about that? I'm also sharing my logs, can provide more info if needed. Many thanks
I, [2022-10-18T22:10:20.628161 #97499] INFO -- : Running example 'Verifying a pact between sms-consumer and sms-provider Given a user was created a create event has matching content'
I, [2022-10-18T22:10:20.629846 #97499] INFO -- : Sending POST request to path: "/" with headers: {"CONTENT_TYPE"=>"application/json", "HTTP_X_PACT_ORIGINAL_HEADER_NAMES"=>"Content-Type", "X_PACT_PROVIDER_STATES"=>[{"name"=>"a user was created"}]}, see debug logs for body
D, [2022-10-18T22:10:20.629899 #97499] DEBUG -- : body :{"description":"a create event","providerStates":[{"name":"a user was created","params":{}}],"metadata":{"Content-Type":"application/json; charset=UTF-8"}}
I, [2022-10-18T22:10:20.646374 #97499] INFO -- : Received response with status: 500, headers: {"Date"=>"Tue, 18 Oct 2022 19:10:20 GMT", "Server"=>"uvicorn", "Content-Length"=>"32", "Content-Type"=>"application/json"}, see debug logs for body
D, [2022-10-18T22:10:20.646463 #97499] DEBUG -- : body: {"detail":"No matched handler."}
Nuno Frias
11/07/2022, 10:15 AMNuno Frias
11/07/2022, 10:15 AMNuno Frias
11/08/2022, 11:17 AMguru raghavendra.r
11/09/2022, 2:29 PMJayesh Guru
11/17/2022, 12:31 AM.will_respond_with(
status=200,
body={
"id": Like(1|None)
}
)
Alan Zhu
11/23/2022, 2:34 AMMohit Soni
11/24/2022, 10:27 AMMohit Soni
11/24/2022, 10:28 AMError Log:
Mohit Soni
11/24/2022, 10:28 AMTraceback:
../../../.pyenv/versions/3.7.13/lib/python3.7/importlib/__init__.py127 in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/pactflow_contract_testing/pact_consumer_api_token.py4 in <module>
from pact import Consumer, Provider
.venv/lib/python3.7/site-packages/pact/__init__.py3 in <module>
from .consumer import Consumer
.venv/lib/python3.7/site-packages/pact/consumer.py2 in <module>
from .pact import Pact
.venv/lib/python3.7/site-packages/pact/pact.py8 in <module>
import psutil
.venv/lib/python3.7/site-packages/psutil/__init__.py123 in <module>
from . import _psosx as _psplatform
.venv/lib/python3.7/site-packages/psutil/_psosx.py13 in <module>
from . import _psposix
.venv/lib/python3.7/site-packages/psutil/_psposix.py28 in <module>
from . import _psutil_osx
E ImportError: dlopen(/<PATH>.venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so, 0x0002): tried: '/.venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Mohit Soni
11/24/2022, 10:28 AMMatt (pactflow.io / pact-js / pact-go)
Mohit Soni
11/24/2022, 12:58 PMMohit Soni
11/24/2022, 1:08 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Yousaf Nabi (pactflow.io)
Tony Nguyen
12/05/2022, 7:58 PMos.environ['PACT_DISABLE_SSL_VERIFICATION'] = 'true'
os.environ['VERBOSE'] = 'true'
Matt (pactflow.io / pact-js / pact-go)
http_proxy
, https_proxy
and no_proxy
)Jayesh Guru
12/07/2022, 6:07 PMGitHub
12/07/2022, 8:21 PMBeth (pactflow.io/Pact Broker/pact-ruby)
Nuno Frias
12/08/2022, 4:43 PMTomasz Rdzak
12/09/2022, 12:02 PMAaron Swerlein
01/06/2023, 4:18 PM