Last active
October 11, 2021 09:39
-
-
Save cankush625/658a976f43fac500fc1ce2d45e16000f to your computer and use it in GitHub Desktop.
This file contains 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
# client.py | |
import request | |
def client_function_name(param) -> bool: | |
response = request.post(url, json="{}"); | |
if response: | |
return True | |
return False | |
# test_client.py | |
from unittest.mock import patch | |
def test_funaction_name(self): | |
with patch("core.client.requests.post") as mock_post: | |
with patch("core.client.client_function_name") as mock_function_name: | |
client = Client("username", "password") | |
response = { | |
"name": "ankush", | |
} | |
mock_post.return_value.status_code = 200 | |
mock_post.return_value.ok = True | |
mock_post.return_value.json.return_value = response | |
resp = client.client_function_name("params_value") | |
self.assertTrue(resp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment