|
4 | 4 | # pylint: disable=too-many-arguments |
5 | 5 |
|
6 | 6 | import os |
7 | | -from threading import Thread |
8 | | -from time import sleep |
9 | 7 |
|
10 | 8 | import pytest |
11 | | -import uvicorn |
12 | 9 | from fastapi import FastAPI |
13 | 10 | from models_library.api_schemas_webserver.licensed_items import ( |
14 | 11 | LicensedItemRpcGet, |
15 | 12 | LicensedItemRpcGetPage, |
16 | 13 | ) |
17 | 14 | from pact.v3 import Verifier |
18 | 15 | from pytest_mock import MockerFixture |
19 | | -from servicelib.utils import unused_port |
20 | 16 | from simcore_service_api_server._meta import API_VERSION |
21 | | -from simcore_service_api_server.api.dependencies.authentication import ( |
22 | | - Identity, |
23 | | - get_current_identity, |
24 | | -) |
25 | 17 | from simcore_service_api_server.api.dependencies.webserver_rpc import ( |
26 | 18 | get_wb_api_rpc_client, |
27 | 19 | ) |
28 | 20 | from simcore_service_api_server.services_rpc.wb_api_server import WbApiRpcClient |
29 | 21 |
|
30 | | - |
31 | | -def mock_get_current_identity() -> Identity: |
32 | | - return Identity( user_id=1, product_name="osparc", email="[email protected]") |
33 | | - |
34 | | - |
35 | 22 | # Fake response based on values from 05_licensed_items.json |
36 | 23 | EXPECTED_LICENSED_ITEMS = [ |
37 | 24 | { |
@@ -164,43 +151,6 @@ async def mock_wb_api_server_rpc(app: FastAPI, mocker: MockerFixture) -> MockerF |
164 | 151 | return mocker |
165 | 152 |
|
166 | 153 |
|
167 | | -@pytest.fixture() |
168 | | -def run_test_server( |
169 | | - # get_free_port: int, |
170 | | - # get_unused_port: int, |
171 | | - app: FastAPI, |
172 | | -): |
173 | | - """ |
174 | | - Spins up a FastAPI server in a background thread and yields a base URL. |
175 | | - The 'mocked_catalog_service' fixture ensures the function is already |
176 | | - patched by the time we start the server. |
177 | | - """ |
178 | | - # Override |
179 | | - app.dependency_overrides[get_current_identity] = mock_get_current_identity |
180 | | - |
181 | | - port = unused_port() |
182 | | - base_url = f"http://localhost:{port}" |
183 | | - |
184 | | - config = uvicorn.Config( |
185 | | - app, |
186 | | - host="localhost", |
187 | | - port=port, |
188 | | - log_level="info", |
189 | | - ) |
190 | | - server = uvicorn.Server(config) |
191 | | - |
192 | | - thread = Thread(target=server.run, daemon=True) |
193 | | - thread.start() |
194 | | - |
195 | | - # Wait a bit for the server to be ready |
196 | | - sleep(1) |
197 | | - |
198 | | - yield base_url # , before_server_start |
199 | | - |
200 | | - server.should_exit = True |
201 | | - thread.join() |
202 | | - |
203 | | - |
204 | 154 | @pytest.mark.skipif( |
205 | 155 | not os.getenv("PACT_BROKER_URL"), |
206 | 156 | reason="This test runs only if PACT_BROKER_URL is provided", |
|
0 commit comments