Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariatta committed Oct 12, 2023
1 parent c26660c commit 6199cdc
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions tests/test_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def patch(self, url, url_vars={}, *, data):

async def test_stage():
# Skip changing labels if the label is already set.
issue = {"labels": [{"name": "awaiting merge"}, {"name": "skip issue"}]}
issue = {"number": 123, "labels": [{"name": "awaiting merge"}, {"name": "skip issue"}]}
issue_url = "https://api.github.com/some/issue"
gh = FakeGH()
await awaiting.stage(gh, issue, awaiting.Blocker.merge)
Expand All @@ -59,6 +59,7 @@ async def test_stage():

# Test deleting an old label and adding a new one.
issue = {
"number": 123,
"labels": [{"name": "awaiting review"}, {"name": "skip issue"}],
"labels_url": "https://api.github.com/repos/python/cpython/issues/42/labels{/name}",
}
Expand All @@ -81,6 +82,7 @@ async def test_opened_draft_pr():
data = {
"action": "opened",
"pull_request": {
"number": 123,
"user": {
"login": username,
},
Expand All @@ -92,7 +94,7 @@ async def test_opened_draft_pr():
teams = [{"name": "python core", "id": 6}]
items = {
f"https://api.github.com/teams/6/memberships/{username}": "OK",
issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
}
gh = FakeGH(
getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
Expand All @@ -118,6 +120,7 @@ async def test_opened_draft_pr():
data["pull_request"]["draft"] = True
encoded_label = "awaiting%20core%20review"
items[issue_url] = {
"number": 123,
"labels": [
{
"url": f"https://api.github.com/repos/python/cpython/labels/{encoded_label}",
Expand Down Expand Up @@ -197,6 +200,7 @@ async def test_opened_pr():
data = {
"action": "opened",
"pull_request": {
"number": 123,
"user": {
"login": username,
},
Expand All @@ -207,7 +211,7 @@ async def test_opened_pr():
teams = [{"name": "python core", "id": 6}]
items = {
f"https://api.github.com/teams/6/memberships/{username}": "OK",
issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
}
gh = FakeGH(
getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
Expand All @@ -224,6 +228,7 @@ async def test_opened_pr():
data = {
"action": "opened",
"pull_request": {
"number": 123,
"user": {
"login": username,
},
Expand All @@ -237,7 +242,7 @@ async def test_opened_pr():
f"https://api.github.com/teams/6/memberships/{username}": gidgethub.BadRequest(
status_code=http.HTTPStatus(404)
),
issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
}
gh = FakeGH(
getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
Expand All @@ -261,6 +266,7 @@ async def test_new_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "open",
Expand All @@ -274,6 +280,7 @@ async def test_new_review():
),
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -298,6 +305,7 @@ async def test_new_review():
),
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -322,6 +330,7 @@ async def test_new_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "open",
Expand All @@ -334,6 +343,7 @@ async def test_new_review():
),
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -359,6 +369,7 @@ async def test_new_review():
"state": "APPROVED",
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "open",
Expand All @@ -369,6 +380,7 @@ async def test_new_review():
items = {
f"https://api.github.com/teams/6/memberships/{username}": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.changes.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -395,6 +407,7 @@ async def test_new_review():
"state": "APPROVED",
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "closed",
Expand All @@ -405,6 +418,7 @@ async def test_new_review():
items = {
f"https://api.github.com/teams/6/memberships/{username}": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.changes.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -427,6 +441,7 @@ async def test_new_review():
"state": "changes_requested".upper(),
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"comments_url": "https://api.github.com/comment/42",
Expand All @@ -441,6 +456,7 @@ async def test_new_review():
status_code=http.HTTPStatus(404)
),
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -465,6 +481,7 @@ async def test_new_review():
"state": "commented".upper(),
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"comments_url": "https://api.github.com/comment/42",
Expand All @@ -486,6 +503,7 @@ async def test_new_review():
"state": "changes_requested".upper(),
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"comments_url": "https://api.github.com/comment/42",
Expand All @@ -496,6 +514,7 @@ async def test_new_review():
items = {
f"https://api.github.com/teams/6/memberships/{username}": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.changes.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -516,6 +535,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -528,6 +548,7 @@ async def test_dismissed_review():
),
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.core_review.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand Down Expand Up @@ -555,6 +576,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -567,6 +589,7 @@ async def test_dismissed_review():
),
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.merge.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -591,6 +614,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -605,6 +629,7 @@ async def test_dismissed_review():
status_code=http.HTTPStatus(404)
),
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.core_review.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -629,6 +654,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -641,6 +667,7 @@ async def test_dismissed_review():
status_code=http.HTTPStatus(404)
),
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.merge.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand Down Expand Up @@ -668,6 +695,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -680,6 +708,7 @@ async def test_dismissed_review():
status_code=http.HTTPStatus(404)
),
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.merge.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand Down Expand Up @@ -707,6 +736,7 @@ async def test_dismissed_review():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
},
Expand All @@ -717,6 +747,7 @@ async def test_dismissed_review():
f"https://api.github.com/teams/6/memberships/{username}": True,
f"https://api.github.com/teams/6/memberships/brettcannonalias": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [{"name": awaiting.Blocker.merge.value}],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -742,6 +773,7 @@ async def test_non_core_dev_does_not_downgrade():
),
f"https://api.github.com/teams/6/memberships/{core_dev}": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand All @@ -757,6 +789,7 @@ async def test_non_core_dev_does_not_downgrade():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "open",
Expand Down Expand Up @@ -786,6 +819,7 @@ async def test_non_core_dev_does_not_downgrade():
},
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"state": "open",
Expand Down Expand Up @@ -837,6 +871,7 @@ async def test_new_comment():
data = {
"action": "created",
"issue": {
"number": 42,
"user": {"login": "andreamcinnes"},
"labels": [],
"labels_url": "https://api.github.com/labels/42",
Expand Down Expand Up @@ -886,6 +921,7 @@ async def test_new_comment():
data = {
"action": "created",
"issue": {
"number": 42,
"user": {"login": "andreamcinnes"},
"labels": [],
"labels_url": "https://api.github.com/labels/42",
Expand Down Expand Up @@ -927,6 +963,7 @@ async def test_change_requested_for_core_dev():
"state": "changes_requested".upper(),
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"comments_url": "https://api.github.com/comment/42",
Expand All @@ -939,6 +976,7 @@ async def test_change_requested_for_core_dev():
f"https://api.github.com/teams/6/memberships/gvanrossum": True,
"https://api.github.com/teams/6/memberships/brettcannon": True,
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand Down Expand Up @@ -975,6 +1013,7 @@ async def test_change_requested_for_non_core_dev():
"state": "changes_requested".upper(),
},
"pull_request": {
"number": 42,
"url": "https://api.github.com/pr/42",
"issue_url": "https://api.github.com/issue/42",
"comments_url": "https://api.github.com/comment/42",
Expand All @@ -989,6 +1028,7 @@ async def test_change_requested_for_non_core_dev():
status_code=http.HTTPStatus(404)
),
"https://api.github.com/issue/42": {
"number": 42,
"labels": [],
"labels_url": "https://api.github.com/labels/42",
},
Expand Down Expand Up @@ -1133,6 +1173,7 @@ async def test_new_commit_pushed_to_approved_pr(issue_url_key, repo_full_name):
],
},
"https://api.github.com/repos/python/cpython/issues/5547": {
"number": 42,
"labels": [{"name": "awaiting merge"}],
"labels_url": "https://api.github.com/repos/python/cpython/issues/5547/labels{/name}",
"pull_request": {
Expand Down

0 comments on commit 6199cdc

Please sign in to comment.