Files
ThothII/harness/tests/test_config_resources.py
T

72 lines
1.6 KiB
Python

from tht.config import (
PgvectorDirectConfig,
PostgresDwhConfig,
ThothRestDwhConfig,
ThothVectorHttpConfig,
load_config,
)
def test_loads_discriminated_dwh_and_vector_resources(tmp_path):
workspace = tmp_path / "workspace.yaml"
workspace.write_text(
"""
dwh:
type: thoth_rest
database:
database: analytics
schema: mart
endpoint:
base_url: https://dwh.example.test/
api_key: dwh-reader
vectors:
type: thoth_vector_http
reader:
base_url: https://vectors.example.test/
api_key: vector-reader
writer:
base_url: https://vectors.example.test/
api_key: vector-writer
roots:
artifacts: build/artifacts
indexes: build/indexes
sessions: build/sessions
"""
)
cfg = load_config(workspace)
assert isinstance(cfg.dwh, ThothRestDwhConfig)
assert cfg.dwh.database.db_schema == "mart"
assert isinstance(cfg.vectors, ThothVectorHttpConfig)
assert cfg.vectors.writer.api_key == "vector-writer"
assert cfg.roots.sessions.as_posix() == "build/sessions"
def test_loads_direct_discriminated_resources(tmp_path):
workspace = tmp_path / "workspace.yaml"
workspace.write_text(
"""
dwh:
type: postgres_direct
connection: &database
host: db
database: analytics
schema: mart
user: reader
password: secret
vectors:
type: pgvector_direct
connection:
<<: *database
schema: vectors
"""
)
cfg = load_config(workspace)
assert isinstance(cfg.dwh, PostgresDwhConfig)
assert cfg.database.transport == "direct"
assert isinstance(cfg.vectors, PgvectorDirectConfig)
assert cfg.vector_db.db_schema == "vectors"