Skip to content

Commit

Permalink
Merge pull request #77 from codecov/dana/feedback-link
Browse files Browse the repository at this point in the history
patch only cov feedback link
  • Loading branch information
dana-yaish committed Aug 29, 2023
2 parents 569d4ee + 27aaf8a commit 72af9ea
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
33 changes: 21 additions & 12 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,29 @@ async def write_section(*args, **kwargs):

class NewFooterSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
repo_service = comparison.repository_service.service
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?src=pr&el=continue). ".format(
links["pull"]
hide_project_coverage = self.settings.get("hide_project_coverage", False)
if hide_project_coverage:
yield ("")
yield (
":loudspeaker: Thoughts on this report? [Let us know!]({0}).".format(
"https://about.codecov.io/pull-request-comment-report/"
)
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
else:
repo_service = comparison.repository_service.service
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?src=pr&el=continue). ".format(
links["pull"]
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
)
)
)


class NewHeaderSectionWriter(BaseSectionWriter):
Expand Down
39 changes: 31 additions & 8 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3778,8 +3778,8 @@ async def test_footer_section_writer_in_github(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "github"
Expand All @@ -3800,8 +3800,8 @@ async def test_footer_section_writer_in_gitlab(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "gitlab"
Expand All @@ -3822,8 +3822,8 @@ async def test_footer_section_writer_in_bitbucket(self, mocker):
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={},
current_yaml=mocker.MagicMock(),
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "bitbucket"
Expand All @@ -3838,6 +3838,30 @@ async def test_footer_section_writer_in_bitbucket(self, mocker):
":loudspeaker: Have feedback on the report? [Share it here](https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4).",
]

@pytest.mark.asyncio
async def test_footer_section_writer_with_project_cov_hidden(self, mocker):
writer = NewFooterSectionWriter(
mocker.MagicMock(),
mocker.MagicMock(),
mocker.MagicMock(),
settings={
"layout": "newheader, files, newfooter",
"hide_project_coverage": True,
},
current_yaml={},
)
mock_comparison = mocker.MagicMock()
mock_comparison.repository_service.service = "bitbucket"
res = list(
await writer.write_section(
mock_comparison, {}, [], links={"pull": "pull.link"}
)
)
assert res == [
"",
":loudspeaker: Thoughts on this report? [Let us know!](https://about.codecov.io/pull-request-comment-report/).",
]


class TestCommentNotifierInNewLayout(object):
@pytest.mark.asyncio
Expand Down Expand Up @@ -4168,8 +4192,7 @@ async def test_build_message_no_project_coverage(
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree#diff-ZmlsZV8xLmdv) | `66.67%` |",
f"",
f"",
f"[:umbrella: View full report in Codecov by Sentry](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=continue). ",
f":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
f":loudspeaker: Thoughts on this report? [Let us know!](https://about.codecov.io/pull-request-comment-report/).",
f"",
]
for exp, res in zip(expected_result, result):
Expand Down

0 comments on commit 72af9ea

Please sign in to comment.