UnderCover/app/fallback.py

36 lines
743 B
Python
Raw Normal View History

2022-09-26 22:47:38 -04:00
import types
import json
2022-09-26 22:47:38 -04:00
class MockConnection:
mock_cursor = types.SimpleNamespace()
mock_cursor.execute = lambda *a: ()
mock_cursor.fetchone = lambda *a: None
mock_cursor.fetchall = lambda *a: []
def __enter__(self, *a) -> object:
2022-09-26 22:47:38 -04:00
return self
def __exit__(self, *a) -> None:
2022-09-26 22:47:38 -04:00
pass
def cursor(self) -> object:
2022-09-26 22:47:38 -04:00
return self.mock_cursor
def commit(self, *a) -> None:
2022-09-26 22:47:38 -04:00
pass
class MockCreator:
@staticmethod
def create(data=None, *a) -> object:
2022-09-26 22:47:38 -04:00
print(json.JSONEncoder(indent=2).encode(data))
result = types.SimpleNamespace()
result.status_code = 200
return result
mock_sender = types.SimpleNamespace()
mock_sender.send = MockCreator()
2022-09-26 22:47:38 -04:00