Skip to content

Commit

Permalink
update to API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Apr 7, 2024
1 parent e9bc146 commit ba52724
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,6 @@ def s3_client(s3) -> botocore.client.BaseClient:
client.delete_bucket(Bucket=bucket_name)


@pytest.fixture(scope='session')
def config_psql_dos(
tmp_path_factory: pytest.tmpdir.TempPathFactory,
postgres_cluster: dict[str, str],
) -> t.Callable[[dict[str, t.Any] | None], dict[str, t.Any]]:
"""Return a profile configuration for the :class:`~aiida.storage.psql_dos.backend.PsqlDosBackend`."""

def factory(
database_name: str | None = None, database_username: str | None = None, database_password: str | None = None
) -> dict[str, t.Any]:
"""Return a storage configuration for the :class:`~aiida.storage.psql_dos.backend.PsqlDosBackend`.
:returns: The storage configuration.
"""
storage_config = postgres_cluster.create_database(
database_name=database_name,
database_username=database_username,
database_password=database_password,
)
storage_config['repository_uri'] = f'file://{tmp_path_factory.mktemp("repository")}'

return storage_config

return factory


@pytest.fixture(scope='session')
def config_psql_s3(
config_psql_dos: t.Callable[[dict[str, t.Any] | None], dict[str, t.Any]],
Expand All @@ -191,10 +165,8 @@ def factory(custom_configuration: dict[str, t.Any] | None = None) -> dict[str, t


@pytest.fixture(scope='session')
def psql_s3_profile(aiida_config, config_psql_s3) -> t.Generator[Profile, None, None]:
def psql_s3_profile(aiida_config, tmp_aiida_profile, config_psql_s3) -> t.Generator[Profile, None, None]:
"""Return a test profile configured for the :class:`aiida_s3.storage.psql_s3.PsqlS3Storage`."""
from aiida.tools.pytest_fixtures.configuration import tmp_aiida_profile

with tmp_aiida_profile(aiida_config, storage_backend='s3.psql_s3', storage_config=config_psql_s3()) as profile:
yield profile

Expand Down Expand Up @@ -334,10 +306,8 @@ def factory(custom_configuration: dict[str, t.Any] | None = None) -> dict[str, t


@pytest.fixture(scope='session')
def psql_aws_s3_profile(aiida_config, config_psql_aws_s3) -> t.Generator[Profile, None, None]:
def psql_aws_s3_profile(aiida_config, tmp_aiida_profile, config_psql_aws_s3) -> t.Generator[Profile, None, None]:
"""Return a test profile configured for the :class:`aiida_s3.storage.psql_aws_s3.PsqlAwsS3Storage`."""
from aiida.tools.pytest_fixtures.configuration import tmp_aiida_profile

with tmp_aiida_profile(
aiida_config, storage_backend='s3.psql_aws_s3', storage_config=config_psql_aws_s3()
) as profile:
Expand Down Expand Up @@ -453,12 +423,12 @@ def factory(custom_configuration: dict[str, t.Any] | None = None) -> dict[str, t
@pytest.fixture(scope='session')
def psql_azure_blob_profile(
aiida_config,
tmp_aiida_profile,
should_mock_azure_blob,
config_psql_azure_blob,
azure_blob_storage,
) -> t.Generator[Profile, None, None] | None:
"""Return a test profile configured for the :class:`aiida_s3.storage.psql_azure_blob.PsqlAzureBlobStorage`."""
from aiida.tools.pytest_fixtures.configuration import tmp_aiida_profile
from aiida_s3.repository.azure_blob import AzureBlobStorageRepositoryBackend

if should_mock_azure_blob:
Expand Down

0 comments on commit ba52724

Please sign in to comment.