Coverage for tests/mocks.py: 94%
47 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 18:52 -0500
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 18:52 -0500
1"""Some mocks for testing"""
2class MockedLogger: # pylint: disable=missing-class-docstring, missing-function-docstring, unused-argument
3 def __init__(self, log):
4 self.log = log
6 def info(self, *args):
7 print(args)
8 for arg in args:
9 self.log.append(arg)
11 def debug(self, *args):
12 print(args)
13 for arg in args:
14 self.log.append(arg)
16 def warning(self, *args):
17 print(args)
18 for arg in args:
19 self.log.append(arg)
22class MockedPoolManager: # pylint: disable=missing-class-docstring, missing-function-docstring, unused-argument
23 def __init__(self, status_code, response_headers, content):
24 self.status_code = status_code
25 self.response_headers = response_headers
26 self.content = content
28 class Response:
29 @property
30 def status(self):
31 return self.status_code
33 @status.setter
34 def status(self, status_code):
35 self.status_code = status_code
37 @property
38 def headers(self):
39 return self.response_headers
41 @headers.setter
42 def headers(self, response_headers):
43 self.response_headers = response_headers
45 @property
46 def data(self):
47 return self.content
49 @data.setter
50 def data(self, content):
51 self.content = content
53 def release_conn(self):
54 print("release_conn")
56 def request(self, method, url, decode_content, preload_content, headers) -> Response:
57 response = self.Response()
58 response.status = self.status_code
59 response.headers = self.response_headers
60 response.data = self.content
61 return response