-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
84 lines (59 loc) · 1.68 KB
/
conftest.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import sys
from typing import Callable
from django.conf import settings
class Blessings:
class Terminal:
def __init__(self):
self.colors = {}
def white(self, lvl: str) -> str:
self.colors['white'] = lvl
return lvl
def blue(self, lvl: str) -> str:
self.colors['blue'] = lvl
return lvl
def yellow(self, lvl: str) -> str:
self.colors['yellow'] = lvl
return lvl
def red(self, lvl: str) -> str:
self.colors['red'] = lvl
return lvl
def bright_red(self, lvl: str) -> str:
self.colors['bright_red'] = lvl
return lvl
class SQLAlchemyEngine:
def __init__(self, *args, **kwargs) -> None:
self.args = args
self.kwargs = kwargs
class SQLAlchemyEvent:
listened_events = []
@classmethod
def listens_for(cls, engine: SQLAlchemyEngine, label: str):
def inner(callback: Callable):
cls.listened_events.append((engine, label, callback))
return inner
class SQLAlchemyQuery:
def __init__(self, *args, **kwargs) -> None:
self.args = args
self.kwargs = kwargs
class SQLAlchemyModule:
create_engine = lambda *args, **kwargs: SQLAlchemyEngine(*args, **kwargs)
event = SQLAlchemyEvent
class SQLAlchemyEngineModule:
Engine = SQLAlchemyEngine
class SQLAlchemySQLModule:
text = SQLAlchemyQuery
def pytest_configure():
settings.configure(
USE_I18N=False,
INSTALLED_APPS=[
"django.contrib.contenttypes",
"django.contrib.auth",
"notalib.django_xauth",
],
CLICKHOUSE_PROFILE=False,
CLICKHOUSE_URL="clickhouse+native://localhost/default"
)
sys.modules["blessings"] = Blessings
sys.modules["sqlalchemy"] = SQLAlchemyModule
sys.modules["sqlalchemy.engine"] = SQLAlchemyEngineModule
sys.modules["sqlalchemy.sql"] = SQLAlchemySQLModule