diff --git a/nucliadb/src/nucliadb/tests/config.py b/nucliadb/src/nucliadb/tests/config.py new file mode 100644 index 0000000000..cab4c65a8d --- /dev/null +++ b/nucliadb/src/nucliadb/tests/config.py @@ -0,0 +1,53 @@ +# Copyright (C) 2021 Bosutech XXI S.L. +# +# nucliadb is offered under the AGPL v3.0 and as commercial software. +# For commercial licensing, contact us at info@nuclia.com. +# +# AGPL: +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +# This is a test fixture which is useful outside nucliadb tests. In particular +# it is used for the testbed. Keeping it under src so it can be imported outside +def reset_config(): + from nucliadb.common.cluster import settings as cluster_settings + from nucliadb.ingest import settings as ingest_settings + from nucliadb.train import settings as train_settings + from nucliadb.writer import settings as writer_settings + from nucliadb_utils import settings as utils_settings + from nucliadb_utils.cache import settings as cache_settings + + all_settings = [ + cluster_settings.settings, + ingest_settings.settings, + train_settings.settings, + writer_settings.settings, + cache_settings.settings, + utils_settings.audit_settings, + utils_settings.http_settings, + utils_settings.indexing_settings, + utils_settings.nuclia_settings, + utils_settings.nucliadb_settings, + utils_settings.storage_settings, + utils_settings.transaction_settings, + ] + for settings in all_settings: + defaults = type(settings)() + for attr, _value in settings: + default_value = getattr(defaults, attr) + setattr(settings, attr, default_value) + + from nucliadb.common.cluster import manager + + manager.INDEX_NODES.clear() diff --git a/nucliadb/tests/fixtures.py b/nucliadb/tests/fixtures.py index 098010cc2e..fac7db6375 100644 --- a/nucliadb/tests/fixtures.py +++ b/nucliadb/tests/fixtures.py @@ -43,6 +43,7 @@ from nucliadb.standalone.config import config_nucliadb from nucliadb.standalone.run import run_async_nucliadb from nucliadb.standalone.settings import Settings +from nucliadb.tests.config import reset_config from nucliadb.writer import API_PREFIX from nucliadb_protos.train_pb2_grpc import TrainStub from nucliadb_protos.utils_pb2 import Relation, RelationNode @@ -91,39 +92,6 @@ def analytics_disabled(): os.environ.pop("NUCLIADB_DISABLE_ANALYTICS") -def reset_config(): - from nucliadb.common.cluster import settings as cluster_settings - from nucliadb.ingest import settings as ingest_settings - from nucliadb.train import settings as train_settings - from nucliadb.writer import settings as writer_settings - from nucliadb_utils import settings as utils_settings - from nucliadb_utils.cache import settings as cache_settings - - all_settings = [ - cluster_settings.settings, - ingest_settings.settings, - train_settings.settings, - writer_settings.settings, - cache_settings.settings, - utils_settings.audit_settings, - utils_settings.http_settings, - utils_settings.indexing_settings, - utils_settings.nuclia_settings, - utils_settings.nucliadb_settings, - utils_settings.storage_settings, - utils_settings.transaction_settings, - ] - for settings in all_settings: - defaults = type(settings)() - for attr, _value in settings: - default_value = getattr(defaults, attr) - setattr(settings, attr, default_value) - - from nucliadb.common.cluster import manager - - manager.INDEX_NODES.clear() - - @pytest.fixture(scope="function") def tmpdir(): try: diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 525602aed8..0000000000 --- a/test-requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -mypy>=1.8 -pytest==7.4.2 -pytest-asyncio~=0.18.0 -pytest-cov==3.0.0 -types-setuptools -types-redis -httpx>=0.23.0 -pytest-docker-fixtures>=1.3.17 -pytest-benchmark -docker>=7.1.0 -grpcio-health-checking==1.44.0 -requests -maturin -pytest-lazy-fixtures -pytest-mock -grpc-stubs>=1.44.0 -aioresponses -# required for pytest-docker-fixtures -psycopg2-binary