-
Notifications
You must be signed in to change notification settings - Fork 4
/
offline_utils.py
34 lines (28 loc) · 1.08 KB
/
offline_utils.py
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
28
29
30
31
32
33
34
#!/usr/bin/env python3
# pylint: disable=R0201
"""Test unit."""
import unittest
from ast import literal_eval
import os
# pylint: disable=R0903
class FakeResponse():
"""To mimic ``requests`` response obj."""
def __init__(self, case_dir):
"""Create fake class."""
status_code_file = os.path.join(os.path.dirname(__file__),
case_dir,
'code.txt')
body_file = os.path.join(os.path.dirname(__file__),
case_dir,
'body.json')
headers_file = os.path.join(os.path.dirname(__file__),
case_dir,
'headers.json')
with open(status_code_file) as file:
self.status_code = int(file.read())
with open(headers_file) as file:
self.headers = literal_eval(file.read())
with open(body_file) as file:
self.text = file.read()
if __name__ == '__main__':
unittest.main()