diff --git a/lib/dl_api_lib_testing/dl_api_lib_testing/configuration.py b/lib/dl_api_lib_testing/dl_api_lib_testing/configuration.py index f49c09f7b..7be36fc7a 100644 --- a/lib/dl_api_lib_testing/dl_api_lib_testing/configuration.py +++ b/lib/dl_api_lib_testing/dl_api_lib_testing/configuration.py @@ -10,11 +10,13 @@ from dl_api_lib.loader import ApiLibraryConfig from dl_configs.connector_availability import ConnectorAvailabilityConfigSettings from dl_core_testing.configuration import CoreTestEnvironmentConfigurationBase +from dl_formula_testing.configuration import FormulaTestEnvironmentConfiguration @attr.s(kw_only=True) class ApiTestEnvironmentConfiguration: - core_test_config: CoreTestEnvironmentConfigurationBase = attr.ib() + core_test_config: CoreTestEnvironmentConfigurationBase = attr.ib(factory=CoreTestEnvironmentConfigurationBase) + formula_test_config: FormulaTestEnvironmentConfiguration = attr.ib(factory=FormulaTestEnvironmentConfiguration) ext_query_executer_secret_key: str = attr.ib() diff --git a/lib/dl_api_lib_testing/dl_api_lib_testing/initialization.py b/lib/dl_api_lib_testing/dl_api_lib_testing/initialization.py index 668198f2f..f41ad03fb 100644 --- a/lib/dl_api_lib_testing/dl_api_lib_testing/initialization.py +++ b/lib/dl_api_lib_testing/dl_api_lib_testing/initialization.py @@ -3,8 +3,10 @@ from dl_api_lib.loader import load_api_lib from dl_api_lib_testing.configuration import ApiTestEnvironmentConfiguration from dl_core_testing.initialization import initialize_core_test +from dl_formula_testing.initialization import initialize_formula_test def initialize_api_lib_test(pytest_config: Config, api_test_config: ApiTestEnvironmentConfiguration) -> None: load_api_lib(api_lib_config=api_test_config.get_api_library_config()) initialize_core_test(pytest_config=pytest_config, core_test_config=api_test_config.core_test_config) + initialize_formula_test(pytest_config=pytest_config, formula_test_config=api_test_config.formula_test_config) diff --git a/lib/dl_formula/dl_formula_tests/unit/conftest.py b/lib/dl_formula/dl_formula_tests/unit/conftest.py index 5a96e2b37..3a43debfe 100644 --- a/lib/dl_formula/dl_formula_tests/unit/conftest.py +++ b/lib/dl_formula/dl_formula_tests/unit/conftest.py @@ -1,17 +1,27 @@ import pytest -from dl_formula.loader import load_formula_lib from dl_formula.parser.base import FormulaParser from dl_formula.parser.factory import ( ParserType, get_parser, ) +from dl_formula_testing.configuration import FormulaTestEnvironmentConfiguration from dl_formula_testing.forced_literal import forced_literal_use # noqa +from dl_formula_testing.initialization import initialize_formula_test PARSERS = (ParserType.antlr_py,) +def pytest_configure(config): # noqa + initialize_formula_test( + pytest_config=config, + formula_test_config=FormulaTestEnvironmentConfiguration( + formula_connector_ep_names=("clickhouse",), + ), + ) + + @pytest.fixture( scope="session", params=PARSERS, @@ -20,8 +30,3 @@ def parser(request) -> FormulaParser: parser_type = request.param return get_parser(parser_type=parser_type) - - -@pytest.fixture(scope="session", autouse=True) -def loaded_bi_libraries() -> None: - load_formula_lib() diff --git a/lib/dl_formula/pyproject.toml b/lib/dl_formula/pyproject.toml index bd473659d..d33c4a0c8 100644 --- a/lib/dl_formula/pyproject.toml +++ b/lib/dl_formula/pyproject.toml @@ -26,7 +26,7 @@ dynamic-enum = {path = "../dynamic_enum"} pytest = ">=7.2.2" pyodbc = ">=4.0.35" python-dateutil = ">=2.8.2" - +datalens-connector-clickhouse = {path = "../dl_connector_clickhouse"} [[tool.mypy.overrides]] module = "ciso8601" diff --git a/lib/dl_formula_testing/dl_formula_testing/configuration.py b/lib/dl_formula_testing/dl_formula_testing/configuration.py new file mode 100644 index 000000000..8632c0f12 --- /dev/null +++ b/lib/dl_formula_testing/dl_formula_testing/configuration.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +from typing import ( + Collection, + Optional, +) + +import attr + +from dl_formula.loader import FormulaLibraryConfig + + +@attr.s(kw_only=True) +class FormulaTestEnvironmentConfiguration: + formula_connector_ep_names: Optional[Collection[str]] = attr.ib(default=None) + + def get_formula_library_config(self) -> FormulaLibraryConfig: + return FormulaLibraryConfig( + formula_connector_ep_names=self.formula_connector_ep_names, + ) diff --git a/lib/dl_formula_testing/dl_formula_testing/initialization.py b/lib/dl_formula_testing/dl_formula_testing/initialization.py new file mode 100644 index 000000000..9bde8a68d --- /dev/null +++ b/lib/dl_formula_testing/dl_formula_testing/initialization.py @@ -0,0 +1,10 @@ +from pytest import Config + +from dl_db_testing.loader import load_db_testing_lib +from dl_formula.loader import load_formula_lib +from dl_formula_testing.configuration import FormulaTestEnvironmentConfiguration + + +def initialize_formula_test(pytest_config: Config, formula_test_config: FormulaTestEnvironmentConfiguration) -> None: + load_db_testing_lib() + load_formula_lib(formula_lib_config=formula_test_config.get_formula_library_config())