forked from dlt-hub/dlt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
62 lines (53 loc) · 1.81 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
import sys
import os
import pytest
from unittest.mock import patch
from dlt.common.configuration.container import Container
from dlt.common.configuration.providers import (
ConfigTomlProvider,
EnvironProvider,
SecretsTomlProvider,
StringTomlProvider,
)
from dlt.common.configuration.specs.config_providers_context import (
ConfigProvidersContext,
)
from dlt.common.utils import set_working_dir
from tests.utils import (
patch_home_dir,
autouse_test_storage,
preserve_environ,
duckdb_pipeline_location,
wipe_pipeline,
)
@pytest.fixture(autouse=True)
def setup_secret_providers(request):
"""Creates set of config providers where tomls are loaded from tests/.dlt"""
secret_dir = "./.dlt"
dname = os.path.dirname(request.module.__file__)
config_dir = dname + "/.dlt"
# inject provider context so the original providers are restored at the end
def _initial_providers():
return [
EnvironProvider(),
SecretsTomlProvider(project_dir=secret_dir, add_global_config=False),
ConfigTomlProvider(project_dir=config_dir, add_global_config=False),
]
glob_ctx = ConfigProvidersContext()
glob_ctx.providers = _initial_providers()
with set_working_dir(dname), Container().injectable_context(glob_ctx), patch(
"dlt.common.configuration.specs.config_providers_context.ConfigProvidersContext.initial_providers",
_initial_providers,
):
# extras work when container updated
glob_ctx.add_extras()
try:
sys.path.insert(0, dname)
yield
finally:
sys.path.pop(0)
def pytest_configure(config):
# push sentry to ci
os.environ["RUNTIME__SENTRY_DSN"] = (
"https://[email protected]/4504819859914752"
)