|
3 | 3 | # pylint: disable=unused-variable |
4 | 4 |
|
5 | 5 |
|
6 | | -import pytest |
7 | 6 | from aiohttp.test_utils import TestClient |
8 | 7 | from simcore_service_storage.s3 import get_s3_client |
9 | 8 | from simcore_service_storage.settings import Settings |
10 | 9 |
|
| 10 | +pytest_simcore_core_services_selection = ["postgres"] |
11 | 11 |
|
12 | | -@pytest.fixture(params=[True, False]) |
13 | | -def enable_s3(request: pytest.FixtureRequest) -> bool: |
14 | | - return request.param # type: ignore |
15 | 12 |
|
16 | | - |
17 | | -@pytest.fixture |
18 | | -def mock_config( |
19 | | - mocked_s3_server_envs, monkeypatch: pytest.MonkeyPatch, enable_s3: bool |
20 | | -): |
21 | | - # NOTE: override services/storage/tests/conftest.py::mock_config |
22 | | - monkeypatch.setenv("STORAGE_POSTGRES", "null") |
23 | | - if not enable_s3: |
24 | | - # disable S3 |
25 | | - monkeypatch.setenv("STORAGE_S3", "null") |
26 | | - |
27 | | - |
28 | | -async def test_s3_client(enable_s3: bool, app_settings: Settings, client: TestClient): |
| 13 | +async def test_s3_client(app_settings: Settings, client: TestClient): |
29 | 14 | assert client.app |
30 | | - if enable_s3: |
31 | | - assert app_settings.STORAGE_S3 |
32 | | - s3_client = get_s3_client(client.app) |
33 | | - assert s3_client |
34 | | - |
35 | | - response = await s3_client.client.list_buckets() |
36 | | - assert response |
37 | | - assert "Buckets" in response |
38 | | - assert len(response["Buckets"]) == 1 |
39 | | - assert "Name" in response["Buckets"][0] |
40 | | - assert response["Buckets"][0]["Name"] == app_settings.STORAGE_S3.S3_BUCKET_NAME |
41 | | - else: |
42 | | - assert not app_settings.STORAGE_S3 |
43 | | - with pytest.raises(KeyError): |
44 | | - get_s3_client(client.app) |
| 15 | + assert app_settings.STORAGE_S3 |
| 16 | + s3_client = get_s3_client(client.app) |
| 17 | + assert s3_client |
| 18 | + |
| 19 | + response = await s3_client.client.list_buckets() |
| 20 | + assert response |
| 21 | + assert "Buckets" in response |
| 22 | + assert len(response["Buckets"]) == 1 |
| 23 | + assert "Name" in response["Buckets"][0] |
| 24 | + assert response["Buckets"][0]["Name"] == app_settings.STORAGE_S3.S3_BUCKET_NAME |
0 commit comments