Skip to content

Instantly share code, notes, and snippets.

@walmsles
Created December 30, 2022 04:28
Show Gist options
  • Save walmsles/981cb19aa916367b0f4d24f9de47cb28 to your computer and use it in GitHub Desktop.
Save walmsles/981cb19aa916367b0f4d24f9de47cb28 to your computer and use it in GitHub Desktop.
from typing import Dict
import pytest
from requests import Request
from tests.e2e.api.infrastructure import EVENT_API_URL
from tests.utils.fetcher import fetch_http_response
@pytest.fixture()
def event_api_url(infrastructure: Dict) -> str:
return infrastructure.get(EVENT_API_URL)
def test_event_api(event_api_url):
# Given
api_data = {"body": "Hello World"}
status_code = 200
# When
response = fetch_http_response(
Request(
method="POST",
url=f"{event_api_url}events",
json={"body": api_data},
)
)
api_response: Dict = response.json()
# Then
# ** we should get a 200 status code and "transaction_id" will be returned in the API response.
assert response.status_code == status_code
assert api_response.get("transaction_id", "Not Found") != "Not Found"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment