Skip to content

Commit ba5f235

Browse files
committed
add headers and status_code to response
1 parent aa03428 commit ba5f235

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

adafruit_fakerequests.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,20 @@
3333

3434

3535
class Fake_Requests:
36-
"""For faking 'requests' using a local file instead of the network."""
36+
"""For faking 'requests' using a local file instead of the network.
3737
38-
def __init__(self, filename: str) -> None:
38+
:param string filename: Name of the file to read.
39+
:param dict headers: Headers to add to the faked response.
40+
:param int status_code: Status code to use to the faked response.
41+
"""
42+
43+
def __init__(self, filename: str, headers=None, status_code=200) -> None:
3944
self._filename = filename
45+
if headers is None:
46+
self.headers = {"content-type": "application/json"}
47+
else:
48+
self.headers = headers
49+
self.status_code = status_code
4050

4151
def json(self) -> Any:
4252
"""json parsed version for local requests."""

0 commit comments

Comments
 (0)