FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python-algorithm/web_programming/test_fetch_github_info.py at master · rasata/Python-algorithm · GitHub
rasata
/
Python-algorithm
Public
forked from
TheAlgorithms/Python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Python-algorithm
/
web_programming
/
test_fetch_github_info.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (20 loc) · 853 Bytes
Breadcrumbs
Python-algorithm
/
web_programming
/
test_fetch_github_info.py
Copy path
File metadata and controls
27 lines (20 loc) · 853 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import
json
import
httpx
from
.
fetch_github_info
import
AUTHENTICATED_USER_ENDPOINT
,
fetch_github_info
def
test_fetch_github_info
(
monkeypatch
):
class
FakeResponse
:
def
__init__
(
self
,
content
)
->
None
:
assert
isinstance
(
content
, (
bytes
,
str
))
self
.
content
=
content
def
json
(
self
):
return
json
.
loads
(
self
.
content
)
def
mock_response
(
*
args
,
**
kwargs
):
assert
args
[
0
]
==
AUTHENTICATED_USER_ENDPOINT
assert
"Authorization"
in
kwargs
[
"headers"
]
assert
kwargs
[
"headers"
][
"Authorization"
].
startswith
(
"token "
)
assert
"Accept"
in
kwargs
[
"headers"
]
return
FakeResponse
(
b'{"login":"test","id":1}'
)
monkeypatch
.
setattr
(
httpx
,
"get"
,
mock_response
)
result
=
fetch_github_info
(
"token"
)
assert
result
[
"login"
]
==
"test"
assert
result
[
"id"
]
==
1
Back
|
FazBrowse Home
|
New Git URL