Created
September 2, 2022 06:40
-
-
Save mojtabaahn/d5a085d05f51f253b8ede0dc86f12c75 to your computer and use it in GitHub Desktop.
Mocking SDKs in python [3]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from httpx import Response, Client | |
from app import app | |
from factories import UserFactory, BasketFactory | |
from unittest.mock import MagicMock | |
def test_purchase_basket_controller(): | |
payment_sdk.get_gateway_url = MagicMock(return_value='https://sample_bank_url.test') | |
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