UnderCover/undercover/fallback.py

36 lines
710 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):
return self
def __exit__(self, *a):
pass
def cursor(self):
return self.mock_cursor
def commit(self, *a):
pass
class MockCreator:
@staticmethod
def create(data=None, *a):
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 = lambda self: MockCreator()