Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions services/webhook/schedule_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Standard imports
from datetime import datetime, timezone
from pathlib import Path
from typing import cast

from config import PRODUCT_ID
Expand Down Expand Up @@ -322,9 +323,11 @@ def schedule_handler(event: EventBridgeSchedulerEvent):

target_path = target_item["full_path"]

# Create issue title and body
statement_coverage = target_item["statement_coverage"]
has_existing_tests = statement_coverage is not None and statement_coverage > 0
# Check if a test file exists for this source file by matching filenames
target_stem = Path(target_path).stem.lower()
has_existing_tests = any(
is_test_file(fp) and target_stem in fp.lower() for fp, _ in all_files_with_sizes
)
title = get_issue_title(target_path, has_existing_tests=has_existing_tests)
body = get_issue_body(
owner=owner_name,
Expand Down
4 changes: 2 additions & 2 deletions utils/files/test_get_impl_file_from_issue_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def test_add_unit_tests_prefix():
assert get_impl_file_from_issue_title(title) == "services/github/client.py"


def test_uncovered_code_prefix():
title = "Schedule: Add tests for uncovered code in utils/helpers.py"
def test_achieve_coverage_prefix():
title = "Schedule: Achieve 100% test coverage for utils/helpers.py"
assert get_impl_file_from_issue_title(title) == "utils/helpers.py"


Expand Down
2 changes: 1 addition & 1 deletion utils/files/test_is_target_test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_is_target_test_file_with_uncovered_code():
{
"owner": "test",
"repo": "test",
"issue_title": "Schedule: Add tests for uncovered code in utils/files/is_test_file.py",
"issue_title": "Schedule: Achieve 100% test coverage for utils/files/is_test_file.py",
},
)

Expand Down
2 changes: 1 addition & 1 deletion utils/issue_templates/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from constants.urls import GH_BASE_URL

SCHEDULE_PREFIX_ADD = "Schedule: Add unit tests to "
SCHEDULE_PREFIX_INCREASE = "Schedule: Add unit tests for uncovered code in "
SCHEDULE_PREFIX_INCREASE = "Schedule: Achieve 100% test coverage for "


def get_issue_title(file_path: str, has_existing_tests: bool = False):
Expand Down
Loading