Skip to content

Instantly share code, notes, and snippets.

@mojtabaahn
Created September 2, 2022 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojtabaahn/f4c7ce7eb65efad50a1d090cd5d8572e to your computer and use it in GitHub Desktop.
Save mojtabaahn/f4c7ce7eb65efad50a1d090cd5d8572e to your computer and use it in GitHub Desktop.
Mocking SDKs in python [2]
from httpx import Response, Client
from app import app
from factories import UserFactory, BasketFactory
def test_purchase_basket_controller():
with Client(app=app, base_url="http://testserver.test", timeout=0.1) as client:
user = UserFactory.create_one()
basket = BasketFactory.create_one(user_id=user.id)
response = client.post(
url='/basket/purchase',
headers=dict(Accept='application/json')
)
assert response.status_code == 307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment