Skip to content

Commit ec28ad4

Browse files
committed
refactor(app-business-reviews): drop importlib boilerplate from tests
With tests/conftest.py putting the integration root on sys.path and the workspace conftest.py patching Integration.load to find config.json, test files can now import the integration with a plain 'from app_business_reviews import app_business_reviews'. Removes the importlib.util.spec_from_file_location dance from both test files and the now-unused dependencies/ sys.path entry. Also deletes the legacy tests/context.py shim from the pre-SDK-2.0 testbed. Matches the simpler pattern used in PRs #280, #289, #306, #307.
1 parent 77c203b commit ec28ad4

3 files changed

Lines changed: 10 additions & 44 deletions

File tree

app-business-reviews/tests/context.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

app-business-reviews/tests/test_app_business_reviews_integration.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,12 @@
1212
"""
1313

1414
import os
15-
import sys
16-
import importlib
17-
import importlib.util
1815

19-
_parent = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
20-
_deps = os.path.abspath(os.path.join(os.path.dirname(__file__), "../dependencies"))
21-
sys.path.insert(0, _parent)
22-
sys.path.insert(0, _deps)
16+
import pytest
17+
from unittest.mock import MagicMock, AsyncMock
18+
from autohive_integrations_sdk import FetchResponse
2319

24-
import pytest # noqa: E402
25-
from unittest.mock import MagicMock, AsyncMock # noqa: E402
26-
from autohive_integrations_sdk import FetchResponse # noqa: E402
27-
28-
_spec = importlib.util.spec_from_file_location("abr_mod", os.path.join(_parent, "app_business_reviews.py"))
29-
_mod = importlib.util.module_from_spec(_spec)
30-
_spec.loader.exec_module(_mod)
31-
32-
abr = _mod.app_business_reviews
20+
from app_business_reviews import app_business_reviews as abr
3321

3422
pytestmark = pytest.mark.integration
3523

app-business-reviews/tests/test_app_business_reviews_unit.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
import os
2-
import sys
3-
import importlib
4-
import importlib.util
5-
6-
_parent = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
7-
_deps = os.path.abspath(os.path.join(os.path.dirname(__file__), "../dependencies"))
8-
sys.path.insert(0, _parent)
9-
sys.path.insert(0, _deps)
10-
11-
import pytest # noqa: E402
12-
from unittest.mock import AsyncMock, MagicMock # noqa: E402
13-
from autohive_integrations_sdk import FetchResponse # noqa: E402
14-
from autohive_integrations_sdk.integration import ResultType # noqa: E402
15-
16-
_spec = importlib.util.spec_from_file_location(
17-
"app_business_reviews_mod", os.path.join(_parent, "app_business_reviews.py")
18-
)
19-
_mod = importlib.util.module_from_spec(_spec)
20-
_spec.loader.exec_module(_mod)
21-
22-
app_business_reviews = _mod.app_business_reviews
1+
import pytest
2+
from unittest.mock import AsyncMock, MagicMock
3+
from autohive_integrations_sdk import FetchResponse
4+
from autohive_integrations_sdk.integration import ResultType
5+
6+
from app_business_reviews import app_business_reviews
237

248
pytestmark = pytest.mark.unit
259

0 commit comments

Comments
 (0)