diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index d96a08dd..7f38caba 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -52,6 +52,14 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject): def __customUrl(self): return self.__repoUrl + "/keys/" + str(self.id) + @property + def created_at(self): + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + @property def id(self): """ @@ -110,28 +118,8 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject): self.__customUrl ) - def edit(self, title=github.GithubObject.NotSet, key=github.GithubObject.NotSet): - """ - :calls: `PATCH /repos/:owner/:repo/keys/:id `_ - :param title: string - :param key: string - :rtype: None - """ - assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title - assert key is github.GithubObject.NotSet or isinstance(key, (str, unicode)), key - post_parameters = dict() - if title is not github.GithubObject.NotSet: - post_parameters["title"] = title - if key is not github.GithubObject.NotSet: - post_parameters["key"] = key - headers, data = self._requester.requestJsonAndCheck( - "PATCH", - self.__customUrl, - input=post_parameters - ) - self._useAttributes(data) - def _initAttributes(self): + self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._key = github.GithubObject.NotSet self._title = github.GithubObject.NotSet @@ -140,6 +128,8 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject): self._read_only = github.GithubObject.NotSet def _useAttributes(self, attributes): + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch diff --git a/github/tests/ReplayData/RepositoryKey.setUp.txt b/github/tests/ReplayData/RepositoryKey.setUp.txt index 1f0ed43e..b1ef2ba9 100644 --- a/github/tests/ReplayData/RepositoryKey.setUp.txt +++ b/github/tests/ReplayData/RepositoryKey.setUp.txt @@ -2,32 +2,32 @@ https GET api.github.com None -/user +/users/lra {'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} None 200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4951'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9c1d83fa3d17bff8351444da9dedded"'), ('date', 'Sat, 26 May 2012 20:32:03 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"type":"User","disk_usage":17080,"hireable":false,"url":"https://api.github.com/users/jacquev6","plan":{"private_repos":5,"name":"micro","collaborators":1,"space":614400},"bio":"","total_private_repos":5,"company":"Criteo","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","public_gists":3,"blog":"http://vincent-jacques.net","email":"vincent@vincent-jacques.net","owned_private_repos":5,"followers":13,"name":"Vincent Jacques","private_gists":5,"collaborators":0,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"public_repos":11,"following":24,"html_url":"https://github.com/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"} +[('content-length', '1350'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '49aa99f015c25437a7443c4d3a58cd17'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"d815d342e9ffdd7a6f1d94fc37e9c605"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4944'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D0B0:6161:CBE72D5:F6C4D85:58AD4915'), ('last-modified', 'Wed, 07 Dec 2016 19:40:08 GMT'), ('date', 'Wed, 22 Feb 2017 08:17:25 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1487754126')] +{"login":"lra","id":122286,"avatar_url":"https://avatars.githubusercontent.com/u/122286?v=3","gravatar_id":"","url":"https://api.github.com/users/lra","html_url":"https://github.com/lra","followers_url":"https://api.github.com/users/lra/followers","following_url":"https://api.github.com/users/lra/following{/other_user}","gists_url":"https://api.github.com/users/lra/gists{/gist_id}","starred_url":"https://api.github.com/users/lra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lra/subscriptions","organizations_url":"https://api.github.com/users/lra/orgs","repos_url":"https://api.github.com/users/lra/repos","events_url":"https://api.github.com/users/lra/events{/privacy}","received_events_url":"https://api.github.com/users/lra/received_events","type":"User","site_admin":false,"name":"Laurent Raufaste","company":"Percolate Industries, Inc.","blog":"http://www.glop.org/","location":"New York, NY","email":"analogue@glop.org","hireable":null,"bio":"Cloud Plumber","public_repos":59,"public_gists":15,"followers":91,"following":34,"created_at":"2009-09-02T08:40:21Z","updated_at":"2016-12-07T19:40:08Z","private_gists":280,"total_private_repos":0,"owned_private_repos":0,"disk_usage":23104,"collaborators":0,"two_factor_authentication":true,"plan":{"name":"free","space":976562499,"collaborators":0,"private_repos":0}} https GET api.github.com None -/repos/jacquev6/PyGithub +/repos/lra/mackup {'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} None 200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4950'), ('content-length', '1129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8794d5a568156ccd5c5753bfeb793ba1"'), ('date', 'Sat, 26 May 2012 20:32:04 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":14,"updated_at":"2012-05-26T18:33:41Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"private":false,"open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T11:25:48Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"git_url":"git://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"} +[('content-length', '4352'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'dc1ce2bfb41810a06c705e83b388572d'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', 'repo'), ('etag', '"bf4fef828839ba79ee9d3f3906930bce"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4943'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D0B1:615D:4E28807:5E17392:58AD4916'), ('last-modified', 'Wed, 22 Feb 2017 05:29:13 GMT'), ('date', 'Wed, 22 Feb 2017 08:17:26 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1487754126')] +{"id":9265294,"name":"mackup","full_name":"lra/mackup","owner":{"login":"lra","id":122286,"avatar_url":"https://avatars.githubusercontent.com/u/122286?v=3","gravatar_id":"","url":"https://api.github.com/users/lra","html_url":"https://github.com/lra","followers_url":"https://api.github.com/users/lra/followers","following_url":"https://api.github.com/users/lra/following{/other_user}","gists_url":"https://api.github.com/users/lra/gists{/gist_id}","starred_url":"https://api.github.com/users/lra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lra/subscriptions","organizations_url":"https://api.github.com/users/lra/orgs","repos_url":"https://api.github.com/users/lra/repos","events_url":"https://api.github.com/users/lra/events{/privacy}","received_events_url":"https://api.github.com/users/lra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lra/mackup","description":"Keep your application settings in sync (OS X/Linux)","fork":false,"url":"https://api.github.com/repos/lra/mackup","forks_url":"https://api.github.com/repos/lra/mackup/forks","keys_url":"https://api.github.com/repos/lra/mackup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lra/mackup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lra/mackup/teams","hooks_url":"https://api.github.com/repos/lra/mackup/hooks","issue_events_url":"https://api.github.com/repos/lra/mackup/issues/events{/number}","events_url":"https://api.github.com/repos/lra/mackup/events","assignees_url":"https://api.github.com/repos/lra/mackup/assignees{/user}","branches_url":"https://api.github.com/repos/lra/mackup/branches{/branch}","tags_url":"https://api.github.com/repos/lra/mackup/tags","blobs_url":"https://api.github.com/repos/lra/mackup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lra/mackup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lra/mackup/git/refs{/sha}","trees_url":"https://api.github.com/repos/lra/mackup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lra/mackup/statuses/{sha}","languages_url":"https://api.github.com/repos/lra/mackup/languages","stargazers_url":"https://api.github.com/repos/lra/mackup/stargazers","contributors_url":"https://api.github.com/repos/lra/mackup/contributors","subscribers_url":"https://api.github.com/repos/lra/mackup/subscribers","subscription_url":"https://api.github.com/repos/lra/mackup/subscription","commits_url":"https://api.github.com/repos/lra/mackup/commits{/sha}","git_commits_url":"https://api.github.com/repos/lra/mackup/git/commits{/sha}","comments_url":"https://api.github.com/repos/lra/mackup/comments{/number}","issue_comment_url":"https://api.github.com/repos/lra/mackup/issues/comments{/number}","contents_url":"https://api.github.com/repos/lra/mackup/contents/{+path}","compare_url":"https://api.github.com/repos/lra/mackup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lra/mackup/merges","archive_url":"https://api.github.com/repos/lra/mackup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lra/mackup/downloads","issues_url":"https://api.github.com/repos/lra/mackup/issues{/number}","pulls_url":"https://api.github.com/repos/lra/mackup/pulls{/number}","milestones_url":"https://api.github.com/repos/lra/mackup/milestones{/number}","notifications_url":"https://api.github.com/repos/lra/mackup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lra/mackup/labels{/name}","releases_url":"https://api.github.com/repos/lra/mackup/releases{/id}","deployments_url":"https://api.github.com/repos/lra/mackup/deployments","created_at":"2013-04-06T19:22:54Z","updated_at":"2017-02-22T05:29:13Z","pushed_at":"2017-02-21T06:53:04Z","git_url":"git://github.com/lra/mackup.git","ssh_url":"git@github.com:lra/mackup.git","clone_url":"https://github.com/lra/mackup.git","svn_url":"https://github.com/lra/mackup","homepage":"","size":1567,"stargazers_count":5775,"watchers_count":5775,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":505,"mirror_url":null,"open_issues_count":165,"forks":505,"open_issues":165,"watchers":5775,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"network_count":505,"subscribers_count":133} https GET api.github.com None -/repos/jacquev6/PyGithub/keys/2626761 +/repos/lra/mackup/keys/21870881 {'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} None 200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4949'), ('content-length', '505'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"96af29920ad069b76bc64517998db752"'), ('date', 'Sat, 26 May 2012 20:32:04 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/user/keys/2626761","verified":true,"key":"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==","title":"Key added through PyGithub","id":2626761} +[('content-length', '563'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'a6882e5cd2513376cb9481dbcd83f3a2'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"6ed85d5716042ec092f92407b0bdc2c6"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4942'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D0B3:615F:8D1E3F1:A96D742:58AD4916'), ('last-modified', 'Wed, 22 Feb 2017 08:16:23 GMT'), ('date', 'Wed, 22 Feb 2017 08:17:26 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1487754126')] +{"id":21870881,"key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLOoLSVPwG1OSgVSeEXNbfIofYdxR5zs3u4PryhnamfFPYwi2vZW3ZxeI1oRcDh2VEdwGvlN5VUduKJNoOWMVzV2jSyR8CeDHH+I0soQCC7kfJVodU96HcPMzZ6MuVwSfD4BFGvKMXyCnBUqzo28BGHFwVQG8Ya9gL6/cTbuWywgM4xaJgMHv1OVcESXBtBkrqOneTJuOgeEmP0RfUnIAK/3/wbg9mfiBq7JV4cmWAg1xNE8GJoAbci59Tdx1dQgVuuqdQGk5jzNusOVneyMtGEB+p7UpPLJsGBW29rsMt7ITUbXM/kl9v11vPtWb+oOUThoFsDYmsWy7fGGP9YAFB","url":"https://api.github.com/repos/lra/mackup/keys/21870881","title":"PyGithub Test Key","verified":true,"created_at":"2017-02-22T08:16:23Z","read_only":true} diff --git a/github/tests/ReplayData/RepositoryKey.testDelete.txt b/github/tests/ReplayData/RepositoryKey.testDelete.txt index bc1d79f4..41eaa3ab 100644 --- a/github/tests/ReplayData/RepositoryKey.testDelete.txt +++ b/github/tests/ReplayData/RepositoryKey.testDelete.txt @@ -2,10 +2,10 @@ https DELETE api.github.com None -/repos/jacquev6/PyGithub/keys/2626761 +/repos/lra/mackup/keys/21870881 {'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} None 204 -[('status', '204 No Content'), ('x-ratelimit-remaining', '4981'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 27 May 2012 11:08:28 GMT')] +[('status', '204 No Content'), ('x-ratelimit-remaining', '4941'), ('x-github-media-type', 'github.v3; format=json'), ('x-content-type-options', 'nosniff'), ('content-security-policy', "default-src 'none'"), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D0B4:6161:CBE73FE:F6C4EF4:58AD4917'), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('vary', 'Accept-Encoding'), ('server', 'GitHub.com'), ('access-control-allow-origin', '*'), ('x-ratelimit-limit', '5000'), ('x-xss-protection', '1; mode=block'), ('x-served-by', '52437fedc85beec8da3449496900fb9a'), ('date', 'Wed, 22 Feb 2017 08:17:27 GMT'), ('x-frame-options', 'deny'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user'), ('x-accepted-oauth-scopes', ''), ('x-ratelimit-reset', '1487754126')] diff --git a/github/tests/ReplayData/RepositoryKey.testEdit.txt b/github/tests/ReplayData/RepositoryKey.testEdit.txt deleted file mode 100644 index 583b3e88..00000000 --- a/github/tests/ReplayData/RepositoryKey.testEdit.txt +++ /dev/null @@ -1,11 +0,0 @@ -https -PATCH -api.github.com -None -/repos/jacquev6/PyGithub/keys/2626761 -{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} -{"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==", "title": "Title edited by PyGithub"} -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '503'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"0e3fe92d1dde4f1bca0df384528bf1e2"'), ('date', 'Sun, 27 May 2012 11:06:26 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/user/keys/2626761","verified":true,"key":"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==","title":"Title edited by PyGithub","id":2626761} - diff --git a/github/tests/ReplayData/RepositoryKey.testEditWithoutParameters.txt b/github/tests/ReplayData/RepositoryKey.testEditWithoutParameters.txt deleted file mode 100644 index d718d9f8..00000000 --- a/github/tests/ReplayData/RepositoryKey.testEditWithoutParameters.txt +++ /dev/null @@ -1,11 +0,0 @@ -https -PATCH -api.github.com -None -/repos/jacquev6/PyGithub/keys/2626761 -{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} -{} -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '503'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"ee6bf384c86aa3147ffa7fcde628072e"'), ('date', 'Sun, 27 May 2012 11:07:43 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/user/keys/2626761","key":"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==","verified":true,"title":"Title edited by PyGithub","id":2626761} - diff --git a/github/tests/RepositoryKey.py b/github/tests/RepositoryKey.py index d12f3a7a..d6573f4a 100644 --- a/github/tests/RepositoryKey.py +++ b/github/tests/RepositoryKey.py @@ -31,29 +31,26 @@ import Framework +import datetime + class RepositoryKey(Framework.TestCase): def setUp(self): Framework.TestCase.setUp(self) - self.key = self.g.get_user().get_repo("PyGithub").get_key(2626761) + # When recording test, be sure to create a deploy key for yourself on + # Github and update it here. + self.key = self.g.get_user("lra").get_repo("mackup").get_key(21870881) def testAttributes(self): - self.assertEqual(self.key.id, 2626761) - self.assertEqual(self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==") - self.assertEqual(self.key.title, "Key added through PyGithub") - self.assertEqual(self.key.url, "https://api.github.com/user/keys/2626761") + self.assertEqual(self.key.id, 21870881) + self.assertEqual(self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLOoLSVPwG1OSgVSeEXNbfIofYdxR5zs3u4PryhnamfFPYwi2vZW3ZxeI1oRcDh2VEdwGvlN5VUduKJNoOWMVzV2jSyR8CeDHH+I0soQCC7kfJVodU96HcPMzZ6MuVwSfD4BFGvKMXyCnBUqzo28BGHFwVQG8Ya9gL6/cTbuWywgM4xaJgMHv1OVcESXBtBkrqOneTJuOgeEmP0RfUnIAK/3/wbg9mfiBq7JV4cmWAg1xNE8GJoAbci59Tdx1dQgVuuqdQGk5jzNusOVneyMtGEB+p7UpPLJsGBW29rsMt7ITUbXM/kl9v11vPtWb+oOUThoFsDYmsWy7fGGP9YAFB") + self.assertEqual(self.key.title, "PyGithub Test Key") + self.assertEqual(self.key.url, "https://api.github.com/repos/lra/mackup/keys/21870881") + self.assertEqual(self.key.created_at, datetime.datetime(2017, 2, 22, 8, 16, 23)) self.assertTrue(self.key.verified) # test __repr__() based on this attributes - self.assertEqual(self.key.__repr__(), 'RepositoryKey(id=2626761)') - - def testEdit(self): - self.key.edit("Title edited by PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==") - self.assertEqual(self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==") - self.assertEqual(self.key.title, "Title edited by PyGithub") - - def testEditWithoutParameters(self): - self.key.edit() + self.assertEqual(self.key.__repr__(), 'RepositoryKey(id=21870881)') def testDelete(self): self.key.delete()