Skip to content

Commit ad25d00

Browse files
authored
♻️ Maintenance: pytest-simcore initial cleanup (#5986)
1 parent 8f141ce commit ad25d00

File tree

332 files changed

+533
-765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+533
-765
lines changed

packages/aws-library/tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import pytest
88

99
pytest_plugins = [
10-
"pytest_simcore.aws_server",
1110
"pytest_simcore.aws_ec2_service",
1211
"pytest_simcore.aws_s3_service",
12+
"pytest_simcore.aws_server",
1313
"pytest_simcore.environment_configs",
14-
"pytest_simcore.repository_paths",
1514
"pytest_simcore.pydantic_models",
1615
"pytest_simcore.pytest_global_environs",
16+
"pytest_simcore.repository_paths",
1717
]
1818

1919

packages/aws-library/tests/test_s3_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from models_library.api_schemas_storage import S3BucketName
1818
from moto.server import ThreadedMotoServer
1919
from pydantic import AnyUrl
20-
from pytest_simcore.helpers.utils_envs import EnvVarsDict
20+
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict
2121
from settings_library.s3 import S3Settings
2222
from types_aiobotocore_s3 import S3Client
2323

packages/dask-task-models-library/tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import pytest
88

99
pytest_plugins = [
10-
"pytest_simcore.repository_paths",
1110
"pytest_simcore.pydantic_models",
1211
"pytest_simcore.pytest_global_environs",
12+
"pytest_simcore.repository_paths",
1313
]
1414

1515

packages/models-library/tests/test_utils_string_substitution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
substitute_all_legacy_identifiers,
1616
upgrade_identifier,
1717
)
18-
from pytest_simcore.helpers.utils_envs import load_dotenv
18+
from pytest_simcore.helpers.monkeypatch_envs import load_dotenv
1919

2020

2121
@pytest.mark.parametrize(

packages/notifications-library/tests/conftest.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
from simcore_postgres_database.models.products import Vendor
1818

1919
pytest_plugins = [
20+
"pytest_simcore.docker_compose",
21+
"pytest_simcore.docker_swarm",
2022
"pytest_simcore.environment_configs",
21-
"pytest_simcore.repository_paths",
2223
"pytest_simcore.faker_payments_data",
2324
"pytest_simcore.faker_products_data",
2425
"pytest_simcore.faker_users_data",
25-
"pytest_simcore.docker_compose",
2626
"pytest_simcore.postgres_service",
27-
"pytest_simcore.docker_swarm",
28-
"pytest_simcore.tmp_path_extra",
27+
"pytest_simcore.repository_paths",
2928
]
3029

3130

packages/notifications-library/tests/email/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import pytest
44
from pydantic import EmailStr
55
from pytest_mock import MockerFixture
6+
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
67
from pytest_simcore.helpers.typing_env import EnvVarsDict
7-
from pytest_simcore.helpers.utils_envs import setenvs_from_dict
88

99

1010
@pytest.fixture

packages/postgres-database/tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from aiopg.sa.engine import Engine
1717
from aiopg.sa.result import ResultProxy, RowProxy
1818
from faker import Faker
19-
from pytest_simcore.helpers.rawdata_fakers import (
19+
from pytest_simcore.helpers.faker_factories import (
2020
random_group,
2121
random_project,
2222
random_user,

packages/postgres-database/tests/products/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from aiopg.sa.exc import ResourceClosedError
1111
from faker import Faker
12-
from pytest_simcore.helpers.rawdata_fakers import random_product
12+
from pytest_simcore.helpers.faker_factories import random_product
1313
from simcore_postgres_database.webserver_models import products
1414
from sqlalchemy.dialects.postgresql import insert as pg_insert
1515

packages/postgres-database/tests/projects/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from aiopg.sa.connection import SAConnection
1111
from aiopg.sa.engine import Engine
1212
from aiopg.sa.result import ResultProxy, RowProxy
13-
from pytest_simcore.helpers.rawdata_fakers import random_project, random_user
13+
from pytest_simcore.helpers.faker_factories import random_project, random_user
1414
from simcore_postgres_database.models.projects import projects
1515
from simcore_postgres_database.models.users import users
1616

packages/postgres-database/tests/test_classifiers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111
import sqlalchemy as sa
1212
from aiopg.sa.engine import Engine
13-
from pytest_simcore.helpers.rawdata_fakers import random_group
13+
from pytest_simcore.helpers.faker_factories import random_group
1414
from simcore_postgres_database.models.classifiers import group_classifiers
1515
from simcore_postgres_database.models.groups import groups
1616
from sqlalchemy import func, literal_column

packages/postgres-database/tests/test_clusters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sqlalchemy as sa
99
from aiopg.sa.engine import Engine
1010
from aiopg.sa.result import ResultProxy
11-
from pytest_simcore.helpers.rawdata_fakers import random_user
11+
from pytest_simcore.helpers.faker_factories import random_user
1212
from simcore_postgres_database.errors import ForeignKeyViolation, NotNullViolation
1313
from simcore_postgres_database.models.cluster_to_groups import cluster_to_groups
1414
from simcore_postgres_database.models.clusters import ClusterType, clusters

packages/postgres-database/tests/test_delete_projects_and_users.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from aiopg.sa.engine import Engine
1010
from aiopg.sa.result import ResultProxy, RowProxy
1111
from psycopg2.errors import ForeignKeyViolation
12-
from pytest_simcore.helpers.rawdata_fakers import random_project, random_user
12+
from pytest_simcore.helpers.faker_factories import random_project, random_user
1313
from simcore_postgres_database.webserver_models import projects, users
1414
from sqlalchemy import func
1515

packages/postgres-database/tests/test_groups.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from aiopg.sa.engine import Engine
1414
from aiopg.sa.result import ResultProxy, RowProxy
1515
from psycopg2.errors import ForeignKeyViolation, RaiseException, UniqueViolation
16-
from pytest_simcore.helpers.rawdata_fakers import random_user
16+
from pytest_simcore.helpers.faker_factories import random_user
1717
from simcore_postgres_database.models.base import metadata
1818
from simcore_postgres_database.webserver_models import (
1919
GroupType,

packages/postgres-database/tests/test_models_api_keys.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sqlalchemy as sa
1010
from aiopg.sa.connection import SAConnection
1111
from aiopg.sa.result import RowProxy
12-
from pytest_simcore.helpers.rawdata_fakers import (
12+
from pytest_simcore.helpers.faker_factories import (
1313
random_api_key,
1414
random_product,
1515
random_user,

packages/postgres-database/tests/test_models_payments_methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from aiopg.sa.connection import SAConnection
1010
from aiopg.sa.result import RowProxy
1111
from faker import Faker
12-
from pytest_simcore.helpers.rawdata_fakers import random_payment_method
12+
from pytest_simcore.helpers.faker_factories import random_payment_method
1313
from simcore_postgres_database.errors import UniqueViolation
1414
from simcore_postgres_database.models.payments_methods import (
1515
InitPromptAckFlowState,

packages/postgres-database/tests/test_models_payments_transactions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from aiopg.sa.connection import SAConnection
1212
from aiopg.sa.result import RowProxy
1313
from faker import Faker
14-
from pytest_simcore.helpers.rawdata_fakers import random_payment_transaction, utcnow
14+
from pytest_simcore.helpers.faker_factories import random_payment_transaction, utcnow
1515
from simcore_postgres_database.models.payments_transactions import (
1616
PaymentTransactionState,
1717
payments_transactions,

packages/postgres-database/tests/test_models_products_prices.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from aiopg.sa.connection import SAConnection
1010
from aiopg.sa.result import RowProxy
1111
from faker import Faker
12-
from pytest_simcore.helpers.rawdata_fakers import random_product
12+
from pytest_simcore.helpers.faker_factories import random_product
1313
from simcore_postgres_database.errors import CheckViolation, ForeignKeyViolation
1414
from simcore_postgres_database.models.products import products
1515
from simcore_postgres_database.models.products_prices import products_prices

packages/postgres-database/tests/test_services_consume_filetypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from aiopg.sa.connection import SAConnection
1212
from aiopg.sa.exc import ResourceClosedError
1313
from aiopg.sa.result import ResultProxy, RowProxy
14-
from pytest_simcore.helpers.utils_services import (
14+
from pytest_simcore.helpers.webserver_fake_services_data import (
1515
FAKE_FILE_CONSUMER_SERVICES,
1616
list_supported_filetypes,
1717
)

packages/postgres-database/tests/test_uniqueness_in_comp_tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99
import sqlalchemy as sa
1010
from psycopg2.errors import UniqueViolation # pylint: disable=no-name-in-module
11-
from pytest_simcore.helpers.rawdata_fakers import fake_pipeline, fake_task_factory
11+
from pytest_simcore.helpers.faker_factories import fake_pipeline, fake_task_factory
1212
from simcore_postgres_database.models.base import metadata
1313
from simcore_postgres_database.webserver_models import comp_pipeline, comp_tasks
1414

packages/postgres-database/tests/test_users.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from aiopg.sa.connection import SAConnection
1111
from aiopg.sa.result import ResultProxy, RowProxy
1212
from faker import Faker
13-
from pytest_simcore.helpers.rawdata_fakers import random_user
13+
from pytest_simcore.helpers.faker_factories import random_user
1414
from simcore_postgres_database.errors import InvalidTextRepresentation, UniqueViolation
1515
from simcore_postgres_database.models.users import (
1616
_USER_ROLE_TO_LEVEL,

packages/postgres-database/tests/test_users_details.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from aiopg.sa.connection import SAConnection
1111
from aiopg.sa.result import RowProxy
1212
from faker import Faker
13-
from pytest_simcore.helpers.rawdata_fakers import (
13+
from pytest_simcore.helpers.faker_factories import (
1414
random_pre_registration_details,
1515
random_user,
1616
)

packages/postgres-database/tests/test_utils_payments_autorecharge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from aiopg.sa.connection import SAConnection
1212
from aiopg.sa.result import RowProxy
1313
from faker import Faker
14-
from pytest_simcore.helpers.rawdata_fakers import random_payment_method, utcnow
14+
from pytest_simcore.helpers.faker_factories import random_payment_method, utcnow
1515
from simcore_postgres_database.models.payments_methods import (
1616
InitPromptAckFlowState,
1717
payments_methods,

packages/postgres-database/tests/test_utils_services.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
import sqlalchemy as sa
1111
from faker import Faker
12-
from pytest_simcore.helpers.rawdata_fakers import random_group
12+
from pytest_simcore.helpers.faker_factories import random_group
1313
from simcore_postgres_database.models.groups import GroupType, groups
1414
from simcore_postgres_database.models.products import products
1515
from simcore_postgres_database.models.services import (

packages/postgres-database/tests/test_utils_tags.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sqlalchemy as sa
1111
from aiopg.sa.connection import SAConnection
1212
from aiopg.sa.result import RowProxy
13-
from pytest_simcore.helpers.utils_tags import create_tag, create_tag_access
13+
from pytest_simcore.helpers.postgres_tags import create_tag, create_tag_access
1414
from simcore_postgres_database.models.tags import tags_to_groups
1515
from simcore_postgres_database.models.users import UserRole, UserStatus
1616
from simcore_postgres_database.utils_tags import (

packages/postgres-database/tests/test_utils_user_preferences.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aiopg.sa.connection import SAConnection
99
from aiopg.sa.result import RowProxy
1010
from faker import Faker
11-
from pytest_simcore.helpers.rawdata_fakers import random_user
11+
from pytest_simcore.helpers.faker_factories import random_user
1212
from simcore_postgres_database.models.users import UserRole, users
1313
from simcore_postgres_database.utils_user_preferences import (
1414
BasePreferencesRepo,

packages/postgres-database/tests/test_utils_users.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from aiopg.sa.connection import SAConnection
1111
from faker import Faker
12-
from pytest_simcore.helpers.rawdata_fakers import random_user
12+
from pytest_simcore.helpers.faker_factories import random_user
1313
from simcore_postgres_database.models.users import UserRole, users
1414
from simcore_postgres_database.utils_users import UserNotFoundInRepoError, UsersRepo
1515

packages/pytest-simcore/src/pytest_simcore/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Collection of tests fixtures for integration testing
22
from importlib.metadata import version
3-
from pathlib import Path
43

54
import pytest
65

@@ -16,8 +15,11 @@ def pytest_addoption(parser: pytest.Parser):
1615
help="Keep stack/registry up after fixtures closes",
1716
)
1817

19-
# DUMMY
20-
parser.addini("HELLO", "Dummy pytest.ini setting")
18+
19+
@pytest.fixture(scope="session")
20+
def keep_docker_up(request: pytest.FixtureRequest) -> bool:
21+
flag: bool = bool(request.config.getoption(name="--keep-docker-up", default=False))
22+
return flag
2123

2224

2325
@pytest.fixture

packages/pytest-simcore/src/pytest_simcore/aioresponses_mocker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from aioresponses import aioresponses as AioResponsesMock # noqa: N812
55

6-
from .helpers.utils_host import get_localhost_ip
6+
from .helpers.host import get_localhost_ip
77

88
# WARNING: any request done through the client will go through aioresponses. It is
99
# unfortunate but that means any valid request (like calling the test server) prefix must be set as passthrough.

packages/pytest-simcore/src/pytest_simcore/aws_server.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from settings_library.ec2 import EC2Settings
1414
from settings_library.s3 import S3Settings
1515

16-
from .helpers.utils_envs import EnvVarsDict, setenvs_from_dict
17-
from .helpers.utils_host import get_localhost_ip
16+
from .helpers.host import get_localhost_ip
17+
from .helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
1818

1919

2020
@pytest.fixture(scope="module")

packages/pytest-simcore/src/pytest_simcore/cli_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Based on https://github.com/Stranger6667/pytest-click
77

88

9-
from typing import Iterator
9+
from collections.abc import Iterator
1010

1111
import pytest
1212
from typer.testing import CliRunner

packages/pytest-simcore/src/pytest_simcore/docker_compose.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@
2828
FIXTURE_CONFIG_OPS_SERVICES_SELECTION,
2929
)
3030
from .helpers.constants import HEADER_STR
31+
from .helpers.docker import run_docker_compose_config, save_docker_infos
32+
from .helpers.host import get_localhost_ip
3133
from .helpers.typing_env import EnvVarsDict
32-
from .helpers.utils_docker import run_docker_compose_config, save_docker_infos
33-
from .helpers.utils_host import get_localhost_ip
34+
35+
36+
@pytest.fixture(scope="module")
37+
def temp_folder(
38+
request: pytest.FixtureRequest, tmp_path_factory: pytest.TempPathFactory
39+
) -> Path:
40+
"""**Module scoped** temporary folder"""
41+
prefix = __name__.replace(".", "_")
42+
return tmp_path_factory.mktemp(
43+
basename=f"{prefix}_temp_folder_{request.module.__name__}", numbered=True
44+
)
3445

3546

3647
@pytest.fixture(scope="session")
@@ -88,8 +99,8 @@ def testing_environ_vars(env_devel_file: Path) -> EnvVarsDict:
8899

89100
@pytest.fixture(scope="module")
90101
def env_file_for_testing(
91-
testing_environ_vars: dict[str, str],
92102
temp_folder: Path,
103+
testing_environ_vars: dict[str, str],
93104
osparc_simcore_root_dir: Path,
94105
) -> Iterator[Path]:
95106
"""Dumps all the environment variables into an $(temp_folder)/.env.test file

packages/pytest-simcore/src/pytest_simcore/docker_registry.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import jsonschema
1717
import pytest
1818
import tenacity
19+
from pytest_simcore.helpers.logging import log_context
1920
from pytest_simcore.helpers.typing_env import EnvVarsDict
20-
from pytest_simcore.logging_utils import log_context
2121
from settings_library.docker_registry import RegistrySettings
2222

23-
from .helpers.utils_host import get_localhost_ip
23+
from .helpers.host import get_localhost_ip
2424

2525
log = logging.getLogger(__name__)
2626

packages/pytest-simcore/src/pytest_simcore/docker_swarm.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
from tenacity.wait import wait_fixed, wait_random_exponential
2424

2525
from .helpers.constants import HEADER_STR, MINUTE
26+
from .helpers.dict_tools import copy_from_dict
27+
from .helpers.host import get_localhost_ip
2628
from .helpers.typing_env import EnvVarsDict
27-
from .helpers.utils_dict import copy_from_dict
28-
from .helpers.utils_host import get_localhost_ip
2929

3030
log = logging.getLogger(__name__)
3131

@@ -146,12 +146,6 @@ def docker_client() -> Iterator[docker.client.DockerClient]:
146146
client.close()
147147

148148

149-
@pytest.fixture(scope="session")
150-
def keep_docker_up(request: pytest.FixtureRequest) -> bool:
151-
flag: bool = request.config.getoption(name="--keep-docker-up", default=False)
152-
return flag
153-
154-
155149
@pytest.fixture(scope="module")
156150
def docker_swarm(
157151
docker_client: docker.client.DockerClient, keep_docker_up: bool

packages/pytest-simcore/src/pytest_simcore/environment_configs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import pytest
1111

12+
from .helpers.monkeypatch_envs import load_dotenv, setenvs_from_dict
1213
from .helpers.typing_env import EnvVarsDict
13-
from .helpers.utils_envs import load_dotenv, setenvs_from_dict
1414

1515

1616
def pytest_addoption(parser: pytest.Parser):

packages/pytest-simcore/src/pytest_simcore/faker_payments_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
PaymentTransactionState,
3030
)
3131

32-
from .helpers.rawdata_fakers import random_payment_transaction
32+
from .helpers.faker_factories import random_payment_transaction
3333

3434

3535
@pytest.fixture

0 commit comments

Comments
 (0)