Skip to content

Commit e8c5feb

Browse files
committed
Adde application so that it could use aiohtp client
1 parent 6cb43aa commit e8c5feb

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

services/storage/tests/conftest.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
from typing import Tuple
1717

1818
import pytest
19+
from aiohttp import web
1920
from aiopg.sa import create_engine
2021

2122
import simcore_service_storage
2223
import utils
24+
from servicelib.application import create_safe_application
2325
from simcore_service_storage.datcore_wrapper import DatcoreWrapper
2426
from simcore_service_storage.dsm import DataStorageManager, DatCoreApiToken
2527
from simcore_service_storage.models import FileMetaData
2628
from simcore_service_storage.settings import SIMCORE_S3_STR
27-
from utils import ACCESS_KEY, BUCKET_NAME, DATABASE, PASS, SECRET_KEY, USER, USER_ID
29+
from utils import (ACCESS_KEY, BUCKET_NAME, DATABASE, PASS, SECRET_KEY, USER,
30+
USER_ID)
2831

2932
current_dir = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
3033
sys.path.append(str(current_dir / "helpers"))
@@ -324,17 +327,33 @@ async def datcore_testbucket(loop, mock_files_factory):
324327

325328

326329
@pytest.fixture(scope="function")
327-
def dsm_fixture(s3_client, postgres_engine, loop):
330+
def moduleless_app(loop, aiohttp_server) -> web.Application:
331+
app: web.Application = create_safe_application()
332+
# creates a dummy server
333+
server = loop.run_until_complete(aiohttp_server(app))
334+
# server is destroyed on exit https://docs.aiohttp.org/en/stable/testing.html#pytest_aiohttp.aiohttp_server
335+
return app
336+
337+
338+
@pytest.fixture(scope="function")
339+
def dsm_fixture(s3_client, postgres_engine, loop, moduleless_app):
328340
pool = ThreadPoolExecutor(3)
341+
329342
dsm_fixture = DataStorageManager(
330-
s3_client, postgres_engine, loop, pool, BUCKET_NAME, False
343+
s3_client=s3_client,
344+
engine=postgres_engine,
345+
loop=loop,
346+
pool=pool,
347+
simcore_bucket_name=BUCKET_NAME,
348+
has_project_db=False,
349+
app=moduleless_app,
331350
)
332351

333352
api_token = os.environ.get("BF_API_KEY", "none")
334353
api_secret = os.environ.get("BF_API_SECRET", "none")
335354
dsm_fixture.datcore_tokens[USER_ID] = DatCoreApiToken(api_token, api_secret)
336355

337-
return dsm_fixture
356+
yield dsm_fixture
338357

339358

340359
@pytest.fixture(scope="function")

0 commit comments

Comments
 (0)