Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cenh-halfspace committed Dec 9, 2024
1 parent c85c923 commit 3ec3f17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/settlement_report_python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def source_path(file_path_finder: Callable[[str], str]) -> str:
`os.chdir()`. The correctness also relies on the prerequisite that this function is
actually located in a file located directly in the tests folder.
"""
return file_path_finder(f"{__file__}/../../..")
return file_path_finder(f"{__file__}/../..")


@pytest.fixture(scope="session")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import pytest
from settlement_report_job.entry_points import entry_point as module

from settlement_report_job.entry_points.entry_point import (
start_zip,
)

# IMPORTANT:
# If we add/remove tests here, we also update the "retry logic" in '.docker/entrypoint.sh',
Expand All @@ -27,14 +29,23 @@
def assert_entry_point_exists(entry_point_name: str) -> Any:
# Load the entry point function from the installed wheel
try:
entry_point = importlib.metadata.entry_points(
entry_points = importlib.metadata.entry_points(
group="console_scripts", name=entry_point_name
)
if not entry_point:

if not entry_points:
assert False, f"The {entry_point_name} entry point was not found."

# Filter for the specific entry point group and name
matching_entry_points = [
ep for ep in entry_points if ep.name == entry_point_name
]

# Check if the module exists
module_name = entry_point[0].module
function_name = entry_point[0].value.split(":")[1]
entry_point = matching_entry_points[0] # Get the single entry point
function_name = entry_point.value.split(":")[1]
full_module_path = entry_point.value.split(":")[0]

if not hasattr(
module,
function_name,
Expand All @@ -43,7 +54,7 @@ def assert_entry_point_exists(entry_point_name: str) -> Any:
False
), f"The entry point module function {function_name} does not exist in entry_point.py."

importlib.import_module(module_name)
importlib.import_module(full_module_path, function_name)
except importlib.metadata.PackageNotFoundError:
assert False, f"The {entry_point_name} entry point was not found."

Expand Down

0 comments on commit 3ec3f17

Please sign in to comment.