import types import json 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): 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()