Skip to content

Commit

Permalink
Add a test for invalid artifact ID (PyGithub#2313)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Fedotov committed Oct 13, 2022
1 parent b125b1d commit c99d11c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/Artifact.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python3

import github

from . import Framework


Expand Down Expand Up @@ -41,6 +43,13 @@ def testGetArtifactsFromRepo(self):
f'Artifact(name="vscode-codeql-extension", id={artifact_id})',
)

def testGetNonexistentArtifact(self):
artifact_id = 396724437
repo_name = "lexa/PyGithub"
repo = self.g.get_repo(repo_name)
with self.assertRaises(github.GithubException):
repo.get_artifact(artifact_id)

def testDelete(self):
artifact_id = 396724439
repo_name = "lexa/PyGithub"
Expand Down
22 changes: 22 additions & 0 deletions tests/ReplayData/Artifact.testGetNonexistentArtifact.txt
@@ -0,0 +1,22 @@
https
GET
api.github.com
None
/repos/lexa/PyGithub
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
None
200
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Oct 2022 11:04:26 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"fa17a5276e7acf7935e265c35562e198168eba7e364cec522ed3c943db34b9ab"'), ('Last-Modified', 'Tue, 27 Sep 2022 16:35:24 GMT'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', 'repo'), ('github-authentication-token-expiration', '2022-12-12 11:42:35 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4998'), ('X-RateLimit-Reset', '1665662666'), ('X-RateLimit-Used', '2'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'BDAE:668A:3A452DF:3B2C773:6347F0BA')]
{"id":542181388,"node_id":"R_kgDOIFEIDA","name":"PyGithub","full_name":"lexa/PyGithub","private":false,"owner":{"login":"lexa","id":80391,"node_id":"MDQ6VXNlcjgwMzkx","avatar_url":"https://avatars.githubusercontent.com/u/80391?v=4","gravatar_id":"","url":"https://api.github.com/users/lexa","html_url":"https://github.com/lexa","followers_url":"https://api.github.com/users/lexa/followers","following_url":"https://api.github.com/users/lexa/following{/other_user}","gists_url":"https://api.github.com/users/lexa/gists{/gist_id}","starred_url":"https://api.github.com/users/lexa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexa/subscriptions","organizations_url":"https://api.github.com/users/lexa/orgs","repos_url":"https://api.github.com/users/lexa/repos","events_url":"https://api.github.com/users/lexa/events{/privacy}","received_events_url":"https://api.github.com/users/lexa/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lexa/PyGithub","description":"Typed interactions with the GitHub API v3","fork":true,"url":"https://api.github.com/repos/lexa/PyGithub","forks_url":"https://api.github.com/repos/lexa/PyGithub/forks","keys_url":"https://api.github.com/repos/lexa/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lexa/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lexa/PyGithub/teams","hooks_url":"https://api.github.com/repos/lexa/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/lexa/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/lexa/PyGithub/events","assignees_url":"https://api.github.com/repos/lexa/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/lexa/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/lexa/PyGithub/tags","blobs_url":"https://api.github.com/repos/lexa/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lexa/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lexa/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/lexa/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lexa/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/lexa/PyGithub/languages","stargazers_url":"https://api.github.com/repos/lexa/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/lexa/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/lexa/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/lexa/PyGithub/subscription","commits_url":"https://api.github.com/repos/lexa/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/lexa/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/lexa/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/lexa/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/lexa/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/lexa/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lexa/PyGithub/merges","archive_url":"https://api.github.com/repos/lexa/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lexa/PyGithub/downloads","issues_url":"https://api.github.com/repos/lexa/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/lexa/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/lexa/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/lexa/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lexa/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/lexa/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/lexa/PyGithub/deployments","created_at":"2022-09-27T16:22:55Z","updated_at":"2022-09-27T16:35:24Z","pushed_at":"2022-10-13T10:44:09Z","git_url":"git://github.com/lexa/PyGithub.git","ssh_url":"git@github.com:lexa/PyGithub.git","clone_url":"https://github.com/lexa/PyGithub.git","svn_url":"https://github.com/lexa/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":11667,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"master","permissions":{"admin":true,"maintain":true,"push":true,"triage":true,"pull":true},"temp_clone_token":"","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE","parent":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2022-10-12T13:43:12Z","pushed_at":"2022-10-13T10:07:22Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":13604,"stargazers_count":5535,"watchers_count":5535,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1533,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":161,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":["github","github-api","pygithub","python"],"visibility":"public","forks":1533,"open_issues":161,"watchers":5535,"default_branch":"master"},"source":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2022-10-12T13:43:12Z","pushed_at":"2022-10-13T10:07:22Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":13604,"stargazers_count":5535,"watchers_count":5535,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1533,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":161,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":["github","github-api","pygithub","python"],"visibility":"public","forks":1533,"open_issues":161,"watchers":5535,"default_branch":"master"},"network_count":1533,"subscribers_count":0}

https
GET
api.github.com
None
/repos/lexa/PyGithub/actions/artifacts/396724437
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
None
404
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Oct 2022 11:04:27 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-12-12 11:42:35 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4997'), ('X-RateLimit-Reset', '1665662666'), ('X-RateLimit-Used', '3'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'BDBA:9294:4077852:415F362:6347F0BB')]
{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/actions#get-an-artifact"}

0 comments on commit c99d11c

Please sign in to comment.