-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72862ad
commit e572c33
Showing
5 changed files
with
340 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
from typing import Generator | ||
import os | ||
from typing import Any, Generator | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
from port_ocean import Ocean | ||
from port_ocean.context.event import EventContext | ||
from port_ocean.context.ocean import initialize_port_ocean_context | ||
from port_ocean.exceptions.context import PortOceanContextAlreadyInitializedError | ||
from port_ocean.tests.helpers.ocean_app import get_integration_ocean_app | ||
|
||
from integration import JiraPortAppConfig | ||
|
||
from .fixtures import ISSUES, PROJECTS | ||
|
||
INTEGRATION_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../")) | ||
|
||
|
||
@pytest.fixture() | ||
|
@@ -24,14 +33,54 @@ def mock_ocean_context() -> None: | |
pass | ||
|
||
|
||
@pytest.fixture | ||
@pytest.fixture(scope="session") | ||
def mock_event_context() -> Generator[MagicMock, None, None]: | ||
"""Fixture to mock the event context.""" | ||
mock_event = MagicMock(spec=EventContext) | ||
mock_event.event_type = "test_event" | ||
mock_event.trigger_type = "manual" | ||
mock_event.attributes = {} | ||
mock_event._aborted = False | ||
mock_event._port_app_config = JiraPortAppConfig | ||
|
||
with patch("port_ocean.context.event.event", mock_event): | ||
yield mock_event | ||
|
||
|
||
def app() -> Ocean: | ||
config = { | ||
"event_listener": {"type": "POLLING"}, | ||
"integration": { | ||
"config": { | ||
"jira_host": "https://getport.atlassian.net", | ||
"atlassian_user_email": "[email protected]", | ||
"atlassian_user_token": "asdf", | ||
} | ||
}, | ||
"port": { | ||
"client_id": "bla", | ||
"client_secret": "bla", | ||
}, | ||
} | ||
application = get_integration_ocean_app(INTEGRATION_PATH, config) | ||
return application | ||
|
||
|
||
@pytest.fixture | ||
def ocean_app() -> Ocean: | ||
return app() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def integration_path() -> str: | ||
return INTEGRATION_PATH | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def projects() -> list[dict[str, Any]]: | ||
return PROJECTS | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def issues() -> list[dict[str, Any]]: | ||
return ISSUES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.