Skip to content

♻️ Maintenance: pytest-simcore initial cleanup #5986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
909e5c6
keep_docker_up fixture moved to init
pcrespov Jun 21, 2024
ce3b52a
logging moved to helpers
pcrespov Jun 21, 2024
343ba55
playwright utils
pcrespov Jun 21, 2024
4118796
rm module fixtures in monkeypatch_extra
pcrespov Jun 21, 2024
e7a9a4a
rm tmp_path-extra and merged into env_file_for_testing
pcrespov Jun 21, 2024
6caf323
rename utils_parametrizations
pcrespov Jun 21, 2024
2adf2ca
socketio fixtures
pcrespov Jun 21, 2024
eaf8746
pause_container -> docker plugin
pcrespov Jun 21, 2024
c698f90
plugin loads
pcrespov Jun 21, 2024
1fc68ec
tmp folder fixture
pcrespov Jun 21, 2024
615a67d
protected validators
pcrespov Jun 24, 2024
895f69b
assert checks
pcrespov Jun 24, 2024
7a8d1a6
rename faker
pcrespov Jun 24, 2024
27c68db
rename utils_envs -> monkeypath_envs
pcrespov Jun 24, 2024
f790c56
docker
pcrespov Jun 24, 2024
0b91d25
webserver
pcrespov Jun 24, 2024
b328697
webserver projects
pcrespov Jun 24, 2024
5f83d26
webserver tokens
pcrespov Jun 24, 2024
6f29782
host and public api
pcrespov Jun 24, 2024
3f8f806
scicrunch
pcrespov Jun 24, 2024
a6b46cf
public api
pcrespov Jun 24, 2024
342c549
param
pcrespov Jun 24, 2024
3c7becd
param
pcrespov Jun 24, 2024
529bab6
ports
pcrespov Jun 24, 2024
3d58de7
rename
pcrespov Jun 24, 2024
46b089a
tooling for dict
pcrespov Jun 24, 2024
cdc170c
rm rate and rename postgres
pcrespov Jun 24, 2024
f6a441e
deprecated
pcrespov Jun 24, 2024
d044b5f
fixes tests
pcrespov Jun 25, 2024
fd30062
Merge branch 'master' into mai/pytest-simcore-refactoring
pcrespov Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions packages/aws-library/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import pytest

pytest_plugins = [
"pytest_simcore.aws_server",
"pytest_simcore.aws_ec2_service",
"pytest_simcore.aws_s3_service",
"pytest_simcore.aws_server",
"pytest_simcore.environment_configs",
"pytest_simcore.repository_paths",
"pytest_simcore.pydantic_models",
"pytest_simcore.pytest_global_environs",
"pytest_simcore.repository_paths",
]


Expand Down
2 changes: 1 addition & 1 deletion packages/aws-library/tests/test_s3_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from models_library.api_schemas_storage import S3BucketName
from moto.server import ThreadedMotoServer
from pydantic import AnyUrl
from pytest_simcore.helpers.utils_envs import EnvVarsDict
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict
from settings_library.s3 import S3Settings
from types_aiobotocore_s3 import S3Client

Expand Down
2 changes: 1 addition & 1 deletion packages/dask-task-models-library/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import pytest

pytest_plugins = [
"pytest_simcore.repository_paths",
"pytest_simcore.pydantic_models",
"pytest_simcore.pytest_global_environs",
"pytest_simcore.repository_paths",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
substitute_all_legacy_identifiers,
upgrade_identifier,
)
from pytest_simcore.helpers.utils_envs import load_dotenv
from pytest_simcore.helpers.monkeypatch_envs import load_dotenv


@pytest.mark.parametrize(
Expand Down
7 changes: 3 additions & 4 deletions packages/notifications-library/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
from simcore_postgres_database.models.products import Vendor

pytest_plugins = [
"pytest_simcore.docker_compose",
"pytest_simcore.docker_swarm",
"pytest_simcore.environment_configs",
"pytest_simcore.repository_paths",
"pytest_simcore.faker_payments_data",
"pytest_simcore.faker_products_data",
"pytest_simcore.faker_users_data",
"pytest_simcore.docker_compose",
"pytest_simcore.postgres_service",
"pytest_simcore.docker_swarm",
"pytest_simcore.tmp_path_extra",
"pytest_simcore.repository_paths",
]


Expand Down
2 changes: 1 addition & 1 deletion packages/notifications-library/tests/email/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from pydantic import EmailStr
from pytest_mock import MockerFixture
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
from pytest_simcore.helpers.typing_env import EnvVarsDict
from pytest_simcore.helpers.utils_envs import setenvs_from_dict


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from aiopg.sa.engine import Engine
from aiopg.sa.result import ResultProxy, RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import (
from pytest_simcore.helpers.faker_factories import (
random_group,
random_project,
random_user,
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/products/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest
from aiopg.sa.exc import ResourceClosedError
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_product
from pytest_simcore.helpers.faker_factories import random_product
from simcore_postgres_database.webserver_models import products
from sqlalchemy.dialects.postgresql import insert as pg_insert

Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/projects/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.engine import Engine
from aiopg.sa.result import ResultProxy, RowProxy
from pytest_simcore.helpers.rawdata_fakers import random_project, random_user
from pytest_simcore.helpers.faker_factories import random_project, random_user
from simcore_postgres_database.models.projects import projects
from simcore_postgres_database.models.users import users

Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest
import sqlalchemy as sa
from aiopg.sa.engine import Engine
from pytest_simcore.helpers.rawdata_fakers import random_group
from pytest_simcore.helpers.faker_factories import random_group
from simcore_postgres_database.models.classifiers import group_classifiers
from simcore_postgres_database.models.groups import groups
from sqlalchemy import func, literal_column
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sqlalchemy as sa
from aiopg.sa.engine import Engine
from aiopg.sa.result import ResultProxy
from pytest_simcore.helpers.rawdata_fakers import random_user
from pytest_simcore.helpers.faker_factories import random_user
from simcore_postgres_database.errors import ForeignKeyViolation, NotNullViolation
from simcore_postgres_database.models.cluster_to_groups import cluster_to_groups
from simcore_postgres_database.models.clusters import ClusterType, clusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from aiopg.sa.engine import Engine
from aiopg.sa.result import ResultProxy, RowProxy
from psycopg2.errors import ForeignKeyViolation
from pytest_simcore.helpers.rawdata_fakers import random_project, random_user
from pytest_simcore.helpers.faker_factories import random_project, random_user
from simcore_postgres_database.webserver_models import projects, users
from sqlalchemy import func

Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from aiopg.sa.engine import Engine
from aiopg.sa.result import ResultProxy, RowProxy
from psycopg2.errors import ForeignKeyViolation, RaiseException, UniqueViolation
from pytest_simcore.helpers.rawdata_fakers import random_user
from pytest_simcore.helpers.faker_factories import random_user
from simcore_postgres_database.models.base import metadata
from simcore_postgres_database.webserver_models import (
GroupType,
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_models_api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sqlalchemy as sa
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from pytest_simcore.helpers.rawdata_fakers import (
from pytest_simcore.helpers.faker_factories import (
random_api_key,
random_product,
random_user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_payment_method
from pytest_simcore.helpers.faker_factories import random_payment_method
from simcore_postgres_database.errors import UniqueViolation
from simcore_postgres_database.models.payments_methods import (
InitPromptAckFlowState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_payment_transaction, utcnow
from pytest_simcore.helpers.faker_factories import random_payment_transaction, utcnow
from simcore_postgres_database.models.payments_transactions import (
PaymentTransactionState,
payments_transactions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_product
from pytest_simcore.helpers.faker_factories import random_product
from simcore_postgres_database.errors import CheckViolation, ForeignKeyViolation
from simcore_postgres_database.models.products import products
from simcore_postgres_database.models.products_prices import products_prices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.exc import ResourceClosedError
from aiopg.sa.result import ResultProxy, RowProxy
from pytest_simcore.helpers.utils_services import (
from pytest_simcore.helpers.webserver_fake_services_data import (
FAKE_FILE_CONSUMER_SERVICES,
list_supported_filetypes,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
import sqlalchemy as sa
from psycopg2.errors import UniqueViolation # pylint: disable=no-name-in-module
from pytest_simcore.helpers.rawdata_fakers import fake_pipeline, fake_task_factory
from pytest_simcore.helpers.faker_factories import fake_pipeline, fake_task_factory
from simcore_postgres_database.models.base import metadata
from simcore_postgres_database.webserver_models import comp_pipeline, comp_tasks

Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import ResultProxy, RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_user
from pytest_simcore.helpers.faker_factories import random_user
from simcore_postgres_database.errors import InvalidTextRepresentation, UniqueViolation
from simcore_postgres_database.models.users import (
_USER_ROLE_TO_LEVEL,
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_users_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import (
from pytest_simcore.helpers.faker_factories import (
random_pre_registration_details,
random_user,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_payment_method, utcnow
from pytest_simcore.helpers.faker_factories import random_payment_method, utcnow
from simcore_postgres_database.models.payments_methods import (
InitPromptAckFlowState,
payments_methods,
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_utils_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest
import sqlalchemy as sa
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_group
from pytest_simcore.helpers.faker_factories import random_group
from simcore_postgres_database.models.groups import GroupType, groups
from simcore_postgres_database.models.products import products
from simcore_postgres_database.models.services import (
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_utils_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sqlalchemy as sa
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from pytest_simcore.helpers.utils_tags import create_tag, create_tag_access
from pytest_simcore.helpers.postgres_tags import create_tag, create_tag_access
from simcore_postgres_database.models.tags import tags_to_groups
from simcore_postgres_database.models.users import UserRole, UserStatus
from simcore_postgres_database.utils_tags import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from aiopg.sa.connection import SAConnection
from aiopg.sa.result import RowProxy
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_user
from pytest_simcore.helpers.faker_factories import random_user
from simcore_postgres_database.models.users import UserRole, users
from simcore_postgres_database.utils_user_preferences import (
BasePreferencesRepo,
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/tests/test_utils_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest
from aiopg.sa.connection import SAConnection
from faker import Faker
from pytest_simcore.helpers.rawdata_fakers import random_user
from pytest_simcore.helpers.faker_factories import random_user
from simcore_postgres_database.models.users import UserRole, users
from simcore_postgres_database.utils_users import UserNotFoundInRepoError, UsersRepo

Expand Down
8 changes: 5 additions & 3 deletions packages/pytest-simcore/src/pytest_simcore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Collection of tests fixtures for integration testing
from importlib.metadata import version
from pathlib import Path

import pytest

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

# DUMMY
parser.addini("HELLO", "Dummy pytest.ini setting")

@pytest.fixture(scope="session")
def keep_docker_up(request: pytest.FixtureRequest) -> bool:
flag: bool = bool(request.config.getoption(name="--keep-docker-up", default=False))
return flag


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from aioresponses import aioresponses as AioResponsesMock # noqa: N812

from .helpers.utils_host import get_localhost_ip
from .helpers.host import get_localhost_ip

# WARNING: any request done through the client will go through aioresponses. It is
# unfortunate but that means any valid request (like calling the test server) prefix must be set as passthrough.
Expand Down
4 changes: 2 additions & 2 deletions packages/pytest-simcore/src/pytest_simcore/aws_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from settings_library.ec2 import EC2Settings
from settings_library.s3 import S3Settings

from .helpers.utils_envs import EnvVarsDict, setenvs_from_dict
from .helpers.utils_host import get_localhost_ip
from .helpers.host import get_localhost_ip
from .helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion packages/pytest-simcore/src/pytest_simcore/cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Based on https://github.com/Stranger6667/pytest-click


from typing import Iterator
from collections.abc import Iterator

import pytest
from typer.testing import CliRunner
Expand Down
17 changes: 14 additions & 3 deletions packages/pytest-simcore/src/pytest_simcore/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@
FIXTURE_CONFIG_OPS_SERVICES_SELECTION,
)
from .helpers.constants import HEADER_STR
from .helpers.docker import run_docker_compose_config, save_docker_infos
from .helpers.host import get_localhost_ip
from .helpers.typing_env import EnvVarsDict
from .helpers.utils_docker import run_docker_compose_config, save_docker_infos
from .helpers.utils_host import get_localhost_ip


@pytest.fixture(scope="module")
def temp_folder(
request: pytest.FixtureRequest, tmp_path_factory: pytest.TempPathFactory
) -> Path:
"""**Module scoped** temporary folder"""
prefix = __name__.replace(".", "_")
return tmp_path_factory.mktemp(
basename=f"{prefix}_temp_folder_{request.module.__name__}", numbered=True
)


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

@pytest.fixture(scope="module")
def env_file_for_testing(
testing_environ_vars: dict[str, str],
temp_folder: Path,
testing_environ_vars: dict[str, str],
osparc_simcore_root_dir: Path,
) -> Iterator[Path]:
"""Dumps all the environment variables into an $(temp_folder)/.env.test file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import jsonschema
import pytest
import tenacity
from pytest_simcore.helpers.logging import log_context
from pytest_simcore.helpers.typing_env import EnvVarsDict
from pytest_simcore.logging_utils import log_context
from settings_library.docker_registry import RegistrySettings

from .helpers.utils_host import get_localhost_ip
from .helpers.host import get_localhost_ip

log = logging.getLogger(__name__)

Expand Down
10 changes: 2 additions & 8 deletions packages/pytest-simcore/src/pytest_simcore/docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from tenacity.wait import wait_fixed, wait_random_exponential

from .helpers.constants import HEADER_STR, MINUTE
from .helpers.dict_tools import copy_from_dict
from .helpers.host import get_localhost_ip
from .helpers.typing_env import EnvVarsDict
from .helpers.utils_dict import copy_from_dict
from .helpers.utils_host import get_localhost_ip

log = logging.getLogger(__name__)

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


@pytest.fixture(scope="session")
def keep_docker_up(request: pytest.FixtureRequest) -> bool:
flag: bool = request.config.getoption(name="--keep-docker-up", default=False)
return flag


@pytest.fixture(scope="module")
def docker_swarm(
docker_client: docker.client.DockerClient, keep_docker_up: bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import pytest

from .helpers.monkeypatch_envs import load_dotenv, setenvs_from_dict
from .helpers.typing_env import EnvVarsDict
from .helpers.utils_envs import load_dotenv, setenvs_from_dict


def pytest_addoption(parser: pytest.Parser):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
PaymentTransactionState,
)

from .helpers.rawdata_fakers import random_payment_transaction
from .helpers.faker_factories import random_payment_transaction


@pytest.fixture
Expand Down
Loading
Loading