From e692b0e0ace895ba19f1bd13eb0c4db8e8456e6c Mon Sep 17 00:00:00 2001 From: erikzaadi Date: Sun, 13 Oct 2024 17:51:53 +0300 Subject: [PATCH] Add optional config overrides in mock ocean app fixture --- port_ocean/tests/helpers/fixtures.py | 6 +++--- port_ocean/tests/helpers/ocean_app.py | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/port_ocean/tests/helpers/fixtures.py b/port_ocean/tests/helpers/fixtures.py index 7c716afb96..a237bc2534 100644 --- a/port_ocean/tests/helpers/fixtures.py +++ b/port_ocean/tests/helpers/fixtures.py @@ -1,5 +1,5 @@ from os import path -from typing import Any, Callable, List, Tuple +from typing import Any, Callable, Dict, List, Tuple, Union import pytest import pytest_asyncio @@ -30,8 +30,8 @@ def port_client_for_fake_integration() -> Tuple[SmokeTestDetails, PortClient]: def get_mocked_ocean_app(request: Any) -> Callable[[], Ocean]: test_dir = path.join(path.dirname(request.module.__file__), "..") - def get_ocean_app() -> Ocean: - return get_integration_ocean_app(test_dir) + def get_ocean_app(config_overrides: Union[Dict[str, Any], None] = None) -> Ocean: + return get_integration_ocean_app(test_dir, config_overrides) return get_ocean_app diff --git a/port_ocean/tests/helpers/ocean_app.py b/port_ocean/tests/helpers/ocean_app.py index 277a0ba03d..6b9f502ac4 100644 --- a/port_ocean/tests/helpers/ocean_app.py +++ b/port_ocean/tests/helpers/ocean_app.py @@ -1,7 +1,7 @@ import sys from inspect import getmembers from pathlib import Path -from typing import List, Tuple +from typing import Any, Dict, List, Tuple, Union from yaml import safe_load @@ -12,7 +12,9 @@ from port_ocean.utils.misc import get_spec_file, load_module -def get_integration_ocean_app(integration_path: str) -> Ocean: +def get_integration_ocean_app( + integration_path: str, config_overrides: Union[Dict[str, Any], None] = None +) -> Ocean: spec_file = get_spec_file(Path(integration_path)) config_factory = None if not spec_file else spec_file.get("configurations", []) @@ -21,9 +23,12 @@ def get_integration_ocean_app(integration_path: str) -> Ocean: integration_path, config_factory, { - "port": { - "client_id": "bla", - "client_secret": "bla", + **(config_overrides or {}), + **{ + "port": { + "client_id": "bla", + "client_secret": "bla", + }, }, }, )