Skip to content

Instantly share code, notes, and snippets.

@cankush625
Last active October 11, 2021 09: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 cankush625/658a976f43fac500fc1ce2d45e16000f to your computer and use it in GitHub Desktop.
Save cankush625/658a976f43fac500fc1ce2d45e16000f to your computer and use it in GitHub Desktop.
# 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