mirror of
https://github.com/dlt-hub/dlt.git
synced 2025-12-17 19:31:30 +00:00
* adds hub extra * makes hub module more user friendly when hub not installed * test and lint fixes * adds plugin version check util function * adds dlt-runtime to hub extra, minimal import tests * bumps to dlthub 0.20.0 alpha * lists pipelines with cli using the same functions as dashboard, dlt pipeline will list pipelines by default * adds configured propfiles method on context so only profiles with configs or pipelines are listed * adds list of locations that contained actual configs to provider interface * improves workspace and profile commands * test fixes * fixes tests
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
from dlt._workspace.providers import ProfileSecretsTomlProvider
|
|
|
|
TESTS_CASES_DIR = os.path.join("tests", "workspace", "cases", "provider")
|
|
|
|
|
|
def test_secrets_toml() -> None:
|
|
provider = ProfileSecretsTomlProvider(os.path.join(TESTS_CASES_DIR, ".dlt"), "access")
|
|
# first access profile, global comes second
|
|
assert provider.locations == [
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/access.secrets.toml")),
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/secrets.toml")),
|
|
]
|
|
assert provider.present_locations == [
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/access.secrets.toml")),
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/secrets.toml")),
|
|
]
|
|
# overrides secrets.toml with profile
|
|
assert provider.get_value("api_key", str, None) == ("PASS", "api_key")
|
|
# still has secrets.toml keys
|
|
assert provider.get_value("log_level", str, None, "runtime") == ("WARNING", "runtime.log_level")
|
|
|
|
# dev profile will load just secrets.toml
|
|
provider = ProfileSecretsTomlProvider(os.path.join(TESTS_CASES_DIR, ".dlt"), "dev")
|
|
assert provider.get_value("api_key", str, None) == ("X", "api_key")
|
|
|
|
|
|
def test_secrets_not_present() -> None:
|
|
provider = ProfileSecretsTomlProvider(os.path.join(TESTS_CASES_DIR, ".dlt"), "unknown")
|
|
# first access profile, global comes second
|
|
assert provider.locations == [
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/unknown.secrets.toml")),
|
|
str(Path(TESTS_CASES_DIR).joinpath(".dlt/secrets.toml")),
|
|
]
|
|
assert provider.present_locations == [str(Path(TESTS_CASES_DIR).joinpath(".dlt/secrets.toml"))]
|