|
10 | 10 | import sys |
11 | 11 | from collections.abc import AsyncGenerator, AsyncIterator, Callable, Iterable |
12 | 12 | from pathlib import Path |
| 13 | +from typing import TypedDict |
13 | 14 |
|
14 | 15 | import httpx |
15 | 16 | import pytest |
|
33 | 34 | from simcore_postgres_database.models.api_keys import api_keys |
34 | 35 | from simcore_postgres_database.models.products import products |
35 | 36 | from simcore_postgres_database.models.users import users |
| 37 | +from simcore_sdk.node_ports_v2 import port |
36 | 38 | from simcore_service_api_server.core.application import init_app |
37 | 39 | from simcore_service_api_server.core.settings import PostgresSettings |
38 | 40 |
|
@@ -73,8 +75,19 @@ def docker_compose_file( |
73 | 75 | return dst_path |
74 | 76 |
|
75 | 77 |
|
| 78 | +class PostgreServiceInfoDict(TypedDict): |
| 79 | + dsn: str |
| 80 | + user: str |
| 81 | + password: str |
| 82 | + host: str |
| 83 | + port: int |
| 84 | + datbase: str |
| 85 | + |
| 86 | + |
76 | 87 | @pytest.fixture(scope="session") |
77 | | -def postgres_service(docker_services, docker_ip, docker_compose_file: Path) -> dict: |
| 88 | +def postgres_service( |
| 89 | + docker_services, docker_ip, docker_compose_file: Path |
| 90 | +) -> PostgreServiceInfoDict: |
78 | 91 | # check docker-compose's environ is resolved properly |
79 | 92 | config = yaml.safe_load(docker_compose_file.read_text()) |
80 | 93 | environ = config["services"]["postgres"]["environment"] |
@@ -110,12 +123,14 @@ def is_postgres_responsive() -> bool: |
110 | 123 | ) |
111 | 124 |
|
112 | 125 | config["dsn"] = dsn |
113 | | - return config |
| 126 | + return PostgreServiceInfoDict(**config) |
114 | 127 |
|
115 | 128 |
|
116 | 129 | @pytest.fixture(scope="session") |
117 | | -def sync_engine(postgres_service: str) -> Iterable[sqlalchemy.engine.Engine]: |
118 | | - _engine: sqlalchemy.engine.Engine = sa.create_engine(url=postgres_service) |
| 130 | +def sync_engine( |
| 131 | + postgres_service: PostgreServiceInfoDict, |
| 132 | +) -> Iterable[sqlalchemy.engine.Engine]: |
| 133 | + _engine: sqlalchemy.engine.Engine = sa.create_engine(url=postgres_service["dsn"]) |
119 | 134 | yield _engine |
120 | 135 | _engine.dispose() |
121 | 136 |
|
|
0 commit comments