MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / mock_response

Function mock_response

web_programming/test_fetch_github_info.py:17–22  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

15 return json.loads(self.content)
16
17 def mock_response(*args, **kwargs):
18 assert args[0] == AUTHENTICATED_USER_ENDPOINT
19 assert "Authorization" in kwargs["headers"]
20 assert kwargs["headers"]["Authorization"].startswith("token ")
21 assert "Accept" in kwargs["headers"]
22 return FakeResponse(b'{"login":"test","id":1}')
23
24 monkeypatch.setattr(httpx, "get", mock_response)
25 result = fetch_github_info("token")

Callers

nothing calls this directly

Calls 1

FakeResponseClass · 0.85

Tested by

no test coverage detected