Skip to content

Commit

Permalink
Deduplicate (pullid,repoid) for tests
Browse files Browse the repository at this point in the history
These tests are reusing ids, which is causing some problems with conflicting keys.
I just used different ids, but we might want something more systemic to generate
unique ids everytime we create a new pull object in the future.
  • Loading branch information
michelletran-codecov committed Oct 22, 2024
1 parent d3812e9 commit 10db8f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ interactions:
user-agent:
- Default
method: POST
uri: https://gitlab.com/api/v4/projects/47404140/merge_requests/1/notes
uri: https://gitlab.com/api/v4/projects/47404140/merge_requests/5/notes
response:
content: "{\"id\":1457135397,\"type\":null,\"body\":\"## [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?src=pr\\\
u0026el=h1\\u0026utm_medium=referral\\u0026utm_source=gitlab\\u0026utm_content=comment\\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interactions:
user-agent:
- Default
method: POST
uri: https://api.github.com/repos/codecove2e/example-python/issues/4/comments
uri: https://api.github.com/repos/codecove2e/example-python/issues/2/comments
response:
content: '{"url":"https://api.github.com/repos/codecove2e/example-python/issues/comments/1361234119","html_url":"https://github.com/codecove2e/example-python/pull/4#issuecomment-1361234119","issue_url":"https://api.github.com/repos/codecove2e/example-python/issues/4","id":1361234119,"node_id":"IC_kwDOHrbKcs5RIsjH","user":{"login":"codecove2e","id":93560619,"node_id":"U_kgDOBZOfKw","avatar_url":"https://avatars.githubusercontent.com/u/93560619?v=4","gravatar_id":"","url":"https://api.github.com/users/codecove2e","html_url":"https://github.com/codecove2e","followers_url":"https://api.github.com/users/codecove2e/followers","following_url":"https://api.github.com/users/codecove2e/following{/other_user}","gists_url":"https://api.github.com/users/codecove2e/gists{/gist_id}","starred_url":"https://api.github.com/users/codecove2e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codecove2e/subscriptions","organizations_url":"https://api.github.com/users/codecove2e/orgs","repos_url":"https://api.github.com/users/codecove2e/repos","events_url":"https://api.github.com/users/codecove2e/events{/privacy}","received_events_url":"https://api.github.com/users/codecove2e/received_events","type":"User","site_admin":false},"created_at":"2022-12-21T12:07:36Z","updated_at":"2022-12-21T12:07:36Z","author_association":"OWNER","body":"The
author of this PR, codecove2e, is not an activated member of this organization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interactions:
user-agent:
- Default
method: POST
uri: https://api.github.com/repos/test-acc9/priv_example/issues/1/comments
uri: https://api.github.com/repos/test-acc9/priv_example/issues/3/comments
response:
content: '{"url":"https://api.github.com/repos/test-acc9/priv_example/issues/comments/1111984446","html_url":"https://github.com/test-acc9/priv_example/pull/1#issuecomment-1111984446","issue_url":"https://api.github.com/repos/test-acc9/priv_example/issues/1","id":1111984446,"node_id":"IC_kwDOHP_eEc5CR4k-","user":{"login":"test-acc9","id":104562106,"node_id":"U_kgDOBjt9ug","avatar_url":"https://avatars.githubusercontent.com/u/104562106?v=4","gravatar_id":"","url":"https://api.github.com/users/test-acc9","html_url":"https://github.com/test-acc9","followers_url":"https://api.github.com/users/test-acc9/followers","following_url":"https://api.github.com/users/test-acc9/following{/other_user}","gists_url":"https://api.github.com/users/test-acc9/gists{/gist_id}","starred_url":"https://api.github.com/users/test-acc9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test-acc9/subscriptions","organizations_url":"https://api.github.com/users/test-acc9/orgs","repos_url":"https://api.github.com/users/test-acc9/repos","events_url":"https://api.github.com/users/test-acc9/events{/privacy}","received_events_url":"https://api.github.com/users/test-acc9/received_events","type":"User","site_admin":false},"created_at":"2022-04-28T09:42:44Z","updated_at":"2022-04-28T09:42:44Z","author_association":"OWNER","body":"#
[Codecov](None/account/gh/test-acc9/billing) upload limit reached :warning:\nThis
Expand Down
30 changes: 15 additions & 15 deletions services/notification/notifiers/tests/integration/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def sample_comparison_gitlab(dbsession, request, sample_report, small_report):
repository=repository,
base=base_commit.commitid,
head=head_commit.commitid,
pullid=1,
pullid=5,
)
dbsession.add(base_commit)
dbsession.add(head_commit)
Expand Down Expand Up @@ -233,7 +233,7 @@ def sample_comparison_for_upgrade(dbsession, request, sample_report, small_repor
repository=repository,
base=base_commit.commitid,
head=head_commit.commitid,
pullid=4,
pullid=2,
)
dbsession.add(base_commit)
dbsession.add(head_commit)
Expand Down Expand Up @@ -298,7 +298,7 @@ def sample_comparison_for_limited_upload(
repository=repository,
base=base_commit.commitid,
head=head_commit.commitid,
pullid=1,
pullid=3,
)
dbsession.add(base_commit)
dbsession.add(head_commit)
Expand Down Expand Up @@ -510,7 +510,7 @@ def test_notify_upgrade(
assert result.data_sent == {
"commentid": None,
"message": expected_message,
"pullid": 4,
"pullid": 2,
}
assert result.data_received == {"id": 1361234119}

Expand Down Expand Up @@ -552,7 +552,7 @@ def test_notify_upload_limited(
assert result.data_sent == {
"commentid": None,
"message": expected_message,
"pullid": 1,
"pullid": 3,
}
assert result.data_received == {"id": 1111984446}

Expand All @@ -576,15 +576,15 @@ def test_notify_gitlab(
assert result.notification_successful
assert result.explanation is None
message = [
"## [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?dropdown=coverage&src=pr&el=h1) Report",
"## [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5?dropdown=coverage&src=pr&el=h1) Report",
"All modified and coverable lines are covered by tests :white_check_mark:",
"> Project coverage is 60.00%. Comparing base [(`0fc784a`)](https://app.codecov.io/gl/joseph-sentry/example-python/commit/0fc784af11c401449e56b24a174bae7b9af86c98?dropdown=coverage&el=desc) to head [(`0b6a213`)](https://app.codecov.io/gl/joseph-sentry/example-python/commit/0b6a213fc300cd328c0625f38f30432ee6e066e5?dropdown=coverage&el=desc).",
"",
"[![Impacted file tree graph](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/graphs/tree.svg?width=650&height=150&src=pr&token=abcdefghij)](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?src=pr&el=tree)",
"[![Impacted file tree graph](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5/graphs/tree.svg?width=650&height=150&src=pr&token=abcdefghij)](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5?src=pr&el=tree)",
"",
"```diff",
"@@ Coverage Diff @@",
"## main #1 +/- ##",
"## main #5 +/- ##",
"=============================================",
"+ Coverage 50.00% 60.00% +10.00% ",
"+ Complexity 11 10 -1 ",
Expand All @@ -598,27 +598,27 @@ def test_notify_gitlab(
"- Partials 0 1 +1 ",
"```",
"",
"| [Flag](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"| [Flag](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
"| [integration](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"| [integration](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"",
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.",
"",
"[see 2 files with indirect coverage changes](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/indirect-changes?src=pr&el=tree-more)",
"[see 2 files with indirect coverage changes](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5/indirect-changes?src=pr&el=tree-more)",
"",
"------",
"",
"[Continue to review full report in Codecov by Sentry](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?dropdown=coverage&src=pr&el=continue).",
"[Continue to review full report in Codecov by Sentry](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5?dropdown=coverage&src=pr&el=continue).",
"> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)",
"> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`",
"> Powered by [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?dropdown=coverage&src=pr&el=footer). Last update [0fc784a...0b6a213](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?dropdown=coverage&src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).",
"> Powered by [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5?dropdown=coverage&src=pr&el=footer). Last update [0fc784a...0b6a213](https://app.codecov.io/gl/joseph-sentry/example-python/pull/5?dropdown=coverage&src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).",
"",
]
for exp, res in zip(result.data_sent["message"], message):
assert exp == res
assert result.data_sent["message"] == message
assert result.data_sent == {"commentid": None, "message": message, "pullid": 1}
assert result.data_sent == {"commentid": None, "message": message, "pullid": 5}
assert result.data_received == {"id": 1457135397}

def test_notify_new_layout(
Expand Down

0 comments on commit 10db8f0

Please sign in to comment.