Skip to content

Commit

Permalink
fix: apply logic to team plan and add test
Browse files Browse the repository at this point in the history
Signed-off-by: joseph-sentry <[email protected]>
  • Loading branch information
joseph-sentry committed May 1, 2024
1 parent a22893f commit e8b369a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
21 changes: 10 additions & 11 deletions services/notification/notifiers/mixins/message/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ def header_lines(self, comparison: ComparisonProxy, diff, settings) -> List[str]

hide_project_coverage = settings.get("hide_project_coverage", False)
if hide_project_coverage:
if comparison.all_tests_passed():
if comparison.test_results_error():
lines.append("")
lines.append(
":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format."
)
else:
lines.append("")
lines.append(
":white_check_mark: All tests successful. No failed tests found."
)
if comparison.test_results_error():
lines.append("")
lines.append(
":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format."
)
elif comparison.all_tests_passed():
lines.append("")
lines.append(
":white_check_mark: All tests successful. No failed tests found."
)

return lines

Expand Down
40 changes: 40 additions & 0 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4974,6 +4974,46 @@ async def test_build_message_team_plan_customer_all_lines_covered_test_results_e
]
assert result == expected_result

@pytest.mark.asyncio
async def test_build_message_team_plan_customer_all_lines_covered(
self,
dbsession,
mock_configuration,
mock_repo_provider,
sample_comparison_coverage_carriedforward,
):
mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br"
sample_comparison_coverage_carriedforward.context = NotificationContext(
all_tests_passed=False,
test_results_error=None,
)
comparison = sample_comparison_coverage_carriedforward
comparison.repository_service.service = "github"
# relevant part of this test
comparison.head.commit.repository.owner.plan = "users-teamm"
notifier = CommentNotifier(
repository=comparison.head.commit.repository,
title="title",
notifier_yaml_settings={
# Irrelevant but they don't overwrite Owner's plan
"layout": "newheader, reach, diff, flags, components, newfooter",
"hide_project_coverage": True,
},
notifier_site_settings=True,
current_yaml={},
)
pull = comparison.pull
repository = sample_comparison_coverage_carriedforward.head.commit.repository
result = await notifier.build_message(comparison)

expected_result = [
f"## [Codecov](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=h1) Report",
"All modified and coverable lines are covered by tests :white_check_mark:",
"",
":loudspeaker: Thoughts on this report? [Let us know!](https://github.com/codecov/feedback/issues/255)",
]
assert result == expected_result

@pytest.mark.asyncio
async def test_build_message_no_patch_or_proj_change(
self,
Expand Down

0 comments on commit e8b369a

Please sign in to comment.