mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Merge pull request #1 from edhollandAL/develop
Freshen master with changes from develop
This commit is contained in:
+5
-1
@@ -150,17 +150,19 @@ class Commit(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.CommitComment.CommitComment(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet):
|
||||
def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet, context=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/statuses/:sha <http://developer.github.com/v3/repos/statuses>`_
|
||||
:param state: string
|
||||
:param target_url: string
|
||||
:param description: string
|
||||
:param context: string
|
||||
:rtype: :class:`github.CommitStatus.CommitStatus`
|
||||
"""
|
||||
assert isinstance(state, (str, unicode)), state
|
||||
assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url
|
||||
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description
|
||||
assert context is github.GithubObject.NotSet or isinstance(context, (str, unicode)), context
|
||||
post_parameters = {
|
||||
"state": state,
|
||||
}
|
||||
@@ -168,6 +170,8 @@ class Commit(github.GithubObject.CompletableGithubObject):
|
||||
post_parameters["target_url"] = target_url
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
if context is not github.GithubObject.NotSet:
|
||||
post_parameters["context"] = context
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self._parentUrl(self._parentUrl(self.url)) + "/statuses/" + self.sha,
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ########################## Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2015 Ed Holland <eholland@alertlogic.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
# ##############################################################################
|
||||
|
||||
import github.GithubObject
|
||||
import github.GitAuthor
|
||||
|
||||
|
||||
class GitRelease(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitRelease as returned for example by https://developer.github.com/v3/repos/releases
|
||||
"""
|
||||
|
||||
@property
|
||||
def body(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._body)
|
||||
return self._body.value
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._title)
|
||||
return self._title.value
|
||||
|
||||
@property
|
||||
def tag_name(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._tag_name)
|
||||
return self._tag_name.value
|
||||
|
||||
@property
|
||||
def author(self):
|
||||
"""
|
||||
:type: :class:`github.GitAuthor.GitAuthor`
|
||||
"""
|
||||
self._completeIfNotSet(self._author)
|
||||
return self._author.value
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._url)
|
||||
return self._url.value
|
||||
|
||||
@property
|
||||
def upload_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._upload_url)
|
||||
return self._upload_url.value
|
||||
|
||||
def delete_release(self):
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url
|
||||
)
|
||||
return True
|
||||
|
||||
def update_release(self, name, message, draft=False, prerelease=False):
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
assert isinstance(message, (str, unicode)), message
|
||||
assert isinstance(draft, bool), draft
|
||||
assert isinstance(prerelease, bool), prerelease
|
||||
post_parameters = {
|
||||
"tag_name": self.tag_name,
|
||||
"name": name,
|
||||
"body": message,
|
||||
"draft": draft,
|
||||
"prerelease": prerelease,
|
||||
}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
input=post_parameters
|
||||
)
|
||||
return github.GitRelease.GitRelease(self._requester, headers, data, completed=True)
|
||||
|
||||
def _initAttributes(self):
|
||||
self._body = github.GithubObject.NotSet
|
||||
self._title = github.GithubObject.NotSet
|
||||
self._tag_name = github.GithubObject.NotSet
|
||||
self._author = github.GithubObject.NotSet
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._upload_url = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "body" in attributes:
|
||||
self._body = self._makeStringAttribute(attributes["body"])
|
||||
if "name" in attributes:
|
||||
self._title = self._makeStringAttribute(attributes["name"])
|
||||
if "tag_name" in attributes:
|
||||
self._tag_name = self._makeStringAttribute(attributes["tag_name"])
|
||||
if "author" in attributes:
|
||||
self._author = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["author"])
|
||||
if "url" in attributes:
|
||||
self._url = self._makeStringAttribute(attributes["url"])
|
||||
if "upload_url" in attributes:
|
||||
self._upload_url = self._makeStringAttribute(attributes["upload_url"])
|
||||
@@ -23,12 +23,14 @@
|
||||
# #
|
||||
# ##############################################################################
|
||||
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class InputGitAuthor(object):
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self, name, email, date):
|
||||
def __init__(self, name, email, date=github.GithubObject.NotSet):
|
||||
"""
|
||||
:param name: string
|
||||
:param email: string
|
||||
@@ -37,15 +39,18 @@ class InputGitAuthor(object):
|
||||
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
assert isinstance(email, (str, unicode)), email
|
||||
assert isinstance(date, (str, unicode)), date # @todo Datetime?
|
||||
assert date is github.GithubObject.NotSet or isinstance(date, (str, unicode)), date # @todo Datetime?
|
||||
|
||||
self.__name = name
|
||||
self.__email = email
|
||||
self.__date = date
|
||||
|
||||
@property
|
||||
def _identity(self):
|
||||
return {
|
||||
identity = {
|
||||
"name": self.__name,
|
||||
"email": self.__email,
|
||||
"date": self.__date,
|
||||
}
|
||||
if self.__date is not github.GithubObject.NotSet:
|
||||
identity["date"] = self.__date
|
||||
return identity
|
||||
|
||||
+4
-1
@@ -189,13 +189,16 @@ class Github(object):
|
||||
)
|
||||
return github.Organization.Organization(self.__requester, headers, data, completed=True)
|
||||
|
||||
def get_repo(self, full_name_or_id):
|
||||
def get_repo(self, full_name_or_id, lazy=True):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_ or `GET /repositories/:id <http://developer.github.com/v3/repos>`_
|
||||
:rtype: :class:`github.Repository.Repository`
|
||||
"""
|
||||
assert isinstance(full_name_or_id, (str, unicode, int)), full_name_or_id
|
||||
url_base = "/repositories/" if isinstance(full_name_or_id, int) else "/repos/"
|
||||
url = "%s%s" % (url_base, full_name_or_id)
|
||||
if lazy:
|
||||
return Repository.Repository(self.__requester, {}, {"url": url}, completed=False)
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"%s%s" % (url_base, full_name_or_id)
|
||||
|
||||
@@ -157,6 +157,7 @@ class PaginatedList(PaginatedListBase):
|
||||
self.__nextUrl,
|
||||
parameters=self.__nextParams
|
||||
)
|
||||
data = data if data else []
|
||||
|
||||
self.__nextUrl = None
|
||||
if len(data) > 0:
|
||||
|
||||
@@ -42,6 +42,7 @@ import github.Label
|
||||
import github.GitBlob
|
||||
import github.Organization
|
||||
import github.GitRef
|
||||
import github.GitRelease
|
||||
import github.Issue
|
||||
import github.Repository
|
||||
import github.PullRequest
|
||||
@@ -743,6 +744,30 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.GitRef.GitRef(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_git_tag_and_release(self, tag, tag_message, release_name, release_message, object, type, tagger=github.GithubObject.NotSet, draft=False, prerelease=False):
|
||||
self.create_git_tag(tag, tag_message, object, type, tagger)
|
||||
return self.create_git_release(tag, release_name, release_message, draft, prerelease)
|
||||
|
||||
def create_git_release(self, tag, name, message, draft=False, prerelease=False):
|
||||
assert isinstance(tag, (str, unicode)), tag
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
assert isinstance(message, (str, unicode)), message
|
||||
assert isinstance(draft, bool), draft
|
||||
assert isinstance(prerelease, bool), prerelease
|
||||
post_parameters = {
|
||||
"tag_name": tag,
|
||||
"name": name,
|
||||
"body": message,
|
||||
"draft": draft,
|
||||
"prerelease": prerelease,
|
||||
}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/releases",
|
||||
input=post_parameters
|
||||
)
|
||||
return github.GitRelease.GitRelease(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_git_tag(self, tag, message, object, type, tagger=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/git/tags <http://developer.github.com/v3/git/tags>`_
|
||||
@@ -1816,6 +1841,37 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
None
|
||||
)
|
||||
|
||||
def get_releases(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/releases <http://developer.github.com/v3/repos>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Tag.Tag`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.GitRelease.GitRelease,
|
||||
self._requester,
|
||||
self.url + "/releases",
|
||||
None
|
||||
)
|
||||
|
||||
def get_release(self, id):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/releases/:id https://developer.github.com/v3/repos/releases/#get-a-single-release
|
||||
:param id: int (release id), str (tag name)
|
||||
:rtype: None or :class:`github.GitRelease.GitRelease`
|
||||
"""
|
||||
if isinstance(id, int):
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/releases/" + str(id)
|
||||
)
|
||||
return github.GitRelease.GitRelease(self._requester, headers, data, completed=True)
|
||||
elif isinstance(id, str):
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/releases/tags/" + id
|
||||
)
|
||||
return github.GitRelease.GitRelease(self._requester, headers, data, completed=True)
|
||||
|
||||
def get_teams(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/teams <http://developer.github.com/v3/repos>`_
|
||||
|
||||
@@ -121,6 +121,18 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
self.url + "/members/" + member._identity
|
||||
)
|
||||
|
||||
def add_membership(self, member):
|
||||
"""
|
||||
:calls: `PUT /teams/:id/memberships/:user <http://developer.github.com/v3/orgs/teams>`_
|
||||
:param member: :class:`github.Nameduser.NamedUser`
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(member, github.NamedUser.NamedUser), member
|
||||
headers, data = self._requester.requestjsonandcheck(
|
||||
"PUT",
|
||||
self.url + "/memberships/" + member._identity
|
||||
)
|
||||
|
||||
def add_to_repos(self, repo):
|
||||
"""
|
||||
:calls: `PUT /teams/:id/repos/:org/:repo <http://developer.github.com/v3/orgs/teams>`_
|
||||
|
||||
@@ -40,6 +40,7 @@ from GitBlob import *
|
||||
from GitCommit import *
|
||||
from Github_ import *
|
||||
from GitRef import *
|
||||
from GitRelease import *
|
||||
from GitTag import *
|
||||
from GitTree import *
|
||||
from Hook import *
|
||||
|
||||
@@ -31,14 +31,14 @@ import github
|
||||
class ConditionalRequestUpdate(Framework.TestCase):
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.repo = self.g.get_repo("akfish/PyGithub")
|
||||
self.repo = self.g.get_repo("akfish/PyGithub", lazy=False)
|
||||
|
||||
def testDidNotUpdate(self):
|
||||
self.assertFalse(self.repo.update(), msg="The repo is not changes. But update() != False")
|
||||
self.assertFalse(self.repo.update(), msg="The repo is not changed. But update() != False")
|
||||
|
||||
def testDidUpdate(self):
|
||||
self.assertTrue(self.repo.update(), msg="The repo should be changed by now. But update() != True")
|
||||
|
||||
def testUpdateObjectWithoutEtag(self):
|
||||
r = self.g.get_repo("jacquev6/PyGithub")
|
||||
r = self.g.get_repo("jacquev6/PyGithub", lazy=False)
|
||||
self.assertTrue(r.update())
|
||||
|
||||
@@ -185,6 +185,7 @@ def ReplayingHttpsConnection(testCase, file, *args, **kwds):
|
||||
|
||||
class BasicTestCase(unittest.TestCase):
|
||||
recordMode = False
|
||||
tokenAuthMode = False
|
||||
|
||||
def setUp(self):
|
||||
unittest.TestCase.setUp(self)
|
||||
@@ -263,8 +264,15 @@ class TestCase(BasicTestCase):
|
||||
github.Requester.Requester.setDebugFlag(True)
|
||||
github.Requester.Requester.setOnCheckMe(self.getFrameChecker())
|
||||
|
||||
self.g = github.Github(self.login, self.password)
|
||||
if self.tokenAuthMode:
|
||||
self.g = github.Github(self.oauth_token)
|
||||
else:
|
||||
self.g = github.Github(self.login, self.password)
|
||||
|
||||
|
||||
def activateRecordMode(): # pragma no cover (Function useful only when recording new tests, not used during automated tests)
|
||||
BasicTestCase.recordMode = True
|
||||
|
||||
|
||||
def activateTokenAuthMode(): # pragma no cover (Function useful only when recording new tests, not used during automated tests)
|
||||
BasicTestCase.tokenAuthMode = True
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ########################## Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2015 Ed Holland <eholland@alertlogic.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
# ##############################################################################
|
||||
|
||||
import Framework
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
class Release(Framework.TestCase):
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
# Do not get self.release here as it casues bad data to be saved in --record mode
|
||||
|
||||
def testAttributes(self):
|
||||
self.release = self.g.get_user().get_repo("PyGithub").get_releases()[0]
|
||||
self.assertEqual(self.release.tag_name, "v1.25.2")
|
||||
self.assertEqual(self.release.upload_url, "https://uploads.github.com/repos/edhollandAL/PyGithub/releases/1210814/assets{?name}")
|
||||
self.assertEqual(self.release.body, "Body")
|
||||
self.assertEqual(self.release.title, "Test")
|
||||
self.assertEqual(self.release.url, "https://api.github.com/repos/edhollandAL/PyGithub/releases/1210814")
|
||||
self.assertEqual(self.release.author._rawData['login'], "edhollandAL")
|
||||
|
||||
def testDelete(self):
|
||||
self.release = self.g.get_user().get_repo("PyGithub").get_releases()[0]
|
||||
self.assertTrue(self.release.delete_release())
|
||||
|
||||
def testUpdate(self):
|
||||
self.release = self.g.get_user().get_repo("PyGithub").get_releases()[0]
|
||||
new_release = self.release.update_release("Updated Test", "Updated Body")
|
||||
self.assertEqual(new_release.body, "Updated Body")
|
||||
self.assertEqual(new_release.title, "Updated Test")
|
||||
|
||||
def testGetRelease(self):
|
||||
release_by_id = self.g.get_user().get_repo("PyGithub").get_release('v1.25.2')
|
||||
release_by_tag = self.g.get_user().get_repo("PyGithub").get_release(1210837)
|
||||
self.assertEqual(release_by_id, release_by_tag)
|
||||
|
||||
def testCreateGitTagAndRelease(self):
|
||||
self.repo = self.g.get_user().get_repo("PyGithub")
|
||||
self.release = self.repo.create_git_tag_and_release('v3.0.0', 'tag message', 'release title', 'release message', '5a05a5e58f682d315acd2447c87ac5b4d4fc55e8', 'commit')
|
||||
self.assertEqual(self.release.tag_name, "v3.0.0")
|
||||
self.assertEqual(self.release.body, "release message")
|
||||
self.assertEqual(self.release.title, "release title")
|
||||
self.assertEqual(self.release.author._rawData['login'], "edhollandAL")
|
||||
@@ -149,3 +149,6 @@ class PaginatedList(Framework.TestCase):
|
||||
def testCustomPerPageWithGetPage(self):
|
||||
self.g.per_page = 100
|
||||
self.assertEqual(len(self.repo.get_issues().get_page(2)), 100)
|
||||
|
||||
def testNoFirstPage(self):
|
||||
self.assertFalse(next(iter(self.list), None))
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/klmitch/turnstile
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('access-control-expose-headers', 'ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes'), ('x-github-request-id', 'b9d67757-009d-4a30-9854-f41e04681849'), ('access-control-allow-credentials', 'true'), ('vary', 'Accept, Authorization, Cookie, Accept-Encoding'), ('content-length', '4587'), ('server', 'GitHub.com'), ('last-modified', 'Wed, 21 Aug 2013 16:04:54 GMT'), ('x-ratelimit-limit', '5000'), ('etag', '"aab62d006633c3842d38e20dc732a2c9"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Thu, 12 Sep 2013 09:09:24 GMT'), ('access-control-allow-origin', '*'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1378980564')]
|
||||
{"id":3404510,"name":"turnstile","full_name":"klmitch/turnstile","owner":{"login":"klmitch","id":686398,"avatar_url":"https://1.gravatar.com/avatar/3c505225c6f28a7702b318a991141495?d=https%3A%2F%2Fidenticons.github.com%2Ffffa0f2e30bad5753edbb60f250b7cbe.png","gravatar_id":"3c505225c6f28a7702b318a991141495","url":"https://api.github.com/users/klmitch","html_url":"https://github.com/klmitch","followers_url":"https://api.github.com/users/klmitch/followers","following_url":"https://api.github.com/users/klmitch/following{/other_user}","gists_url":"https://api.github.com/users/klmitch/gists{/gist_id}","starred_url":"https://api.github.com/users/klmitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klmitch/subscriptions","organizations_url":"https://api.github.com/users/klmitch/orgs","repos_url":"https://api.github.com/users/klmitch/repos","events_url":"https://api.github.com/users/klmitch/events{/privacy}","received_events_url":"https://api.github.com/users/klmitch/received_events","type":"User"},"private":false,"html_url":"https://github.com/klmitch/turnstile","description":"A distributed rate limiting WSGI middleware.","fork":false,"url":"https://api.github.com/repos/klmitch/turnstile","forks_url":"https://api.github.com/repos/klmitch/turnstile/forks","keys_url":"https://api.github.com/repos/klmitch/turnstile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klmitch/turnstile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klmitch/turnstile/teams","hooks_url":"https://api.github.com/repos/klmitch/turnstile/hooks","issue_events_url":"https://api.github.com/repos/klmitch/turnstile/issues/events{/number}","events_url":"https://api.github.com/repos/klmitch/turnstile/events","assignees_url":"https://api.github.com/repos/klmitch/turnstile/assignees{/user}","branches_url":"https://api.github.com/repos/klmitch/turnstile/branches{/branch}","tags_url":"https://api.github.com/repos/klmitch/turnstile/tags","blobs_url":"https://api.github.com/repos/klmitch/turnstile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klmitch/turnstile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klmitch/turnstile/git/refs{/sha}","trees_url":"https://api.github.com/repos/klmitch/turnstile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klmitch/turnstile/statuses/{sha}","languages_url":"https://api.github.com/repos/klmitch/turnstile/languages","stargazers_url":"https://api.github.com/repos/klmitch/turnstile/stargazers","contributors_url":"https://api.github.com/repos/klmitch/turnstile/contributors","subscribers_url":"https://api.github.com/repos/klmitch/turnstile/subscribers","subscription_url":"https://api.github.com/repos/klmitch/turnstile/subscription","commits_url":"https://api.github.com/repos/klmitch/turnstile/commits{/sha}","git_commits_url":"https://api.github.com/repos/klmitch/turnstile/git/commits{/sha}","comments_url":"https://api.github.com/repos/klmitch/turnstile/comments{/number}","issue_comment_url":"https://api.github.com/repos/klmitch/turnstile/issues/comments/{number}","contents_url":"https://api.github.com/repos/klmitch/turnstile/contents/{+path}","compare_url":"https://api.github.com/repos/klmitch/turnstile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klmitch/turnstile/merges","archive_url":"https://api.github.com/repos/klmitch/turnstile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klmitch/turnstile/downloads","issues_url":"https://api.github.com/repos/klmitch/turnstile/issues{/number}","pulls_url":"https://api.github.com/repos/klmitch/turnstile/pulls{/number}","milestones_url":"https://api.github.com/repos/klmitch/turnstile/milestones{/number}","notifications_url":"https://api.github.com/repos/klmitch/turnstile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klmitch/turnstile/labels{/name}","created_at":"2012-02-10T05:16:36Z","updated_at":"2013-08-21T16:04:54Z","pushed_at":"2013-05-01T22:22:20Z","git_url":"git://github.com/klmitch/turnstile.git","ssh_url":"git@github.com:klmitch/turnstile.git","clone_url":"https://github.com/klmitch/turnstile.git","svn_url":"https://github.com/klmitch/turnstile","homepage":"","size":260,"watchers_count":15,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":15,"master_branch":"master","default_branch":"master","permissions":{"admin":false,"push":false,"pull":true},"network_count":6}
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/user
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('content-length', '1304'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', 'c6c65e5196703428e7641f7d1e9bc353'), ('x-oauth-scopes', 'gist, repo, user'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"975c21d2f55751d13745ffc5fa12b1c2"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4960'), ('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', '6CE875F7:1E5F:42689E:5514C7D8'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('last-modified', 'Fri, 27 Mar 2015 02:56:43 GMT'), ('date', 'Fri, 27 Mar 2015 03:00:40 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', '1427427963')]
|
||||
{"login":"korfuri","id":1124263,"avatar_url":"https://avatars.githubusercontent.com/u/1124263?v=3","gravatar_id":"","url":"https://api.github.com/users/korfuri","html_url":"https://github.com/korfuri","followers_url":"https://api.github.com/users/korfuri/followers","following_url":"https://api.github.com/users/korfuri/following{/other_user}","gists_url":"https://api.github.com/users/korfuri/gists{/gist_id}","starred_url":"https://api.github.com/users/korfuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/korfuri/subscriptions","organizations_url":"https://api.github.com/users/korfuri/orgs","repos_url":"https://api.github.com/users/korfuri/repos","events_url":"https://api.github.com/users/korfuri/events{/privacy}","received_events_url":"https://api.github.com/users/korfuri/received_events","type":"User","site_admin":false,"name":"Uriel Corfa","company":"","blog":"http://korfuri.fr/","location":"","email":"uriel@corfa.fr","hireable":false,"bio":null,"public_repos":13,"public_gists":0,"followers":29,"following":57,"created_at":"2011-10-13T02:27:26Z","updated_at":"2015-03-27T02:56:43Z","private_gists":0,"total_private_repos":0,"owned_private_repos":0,"disk_usage":444,"collaborators":0,"plan":{"name":"free","space":976562499,"collaborators":0,"private_repos":0}}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/user
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('content-length', '1304'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '07ff1c8a09e44b62e277fae50a1b1dc4'), ('x-oauth-scopes', 'gist, repo, user'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"6754cf6361cd6d31646de909f5c90146"'), ('access-control-allow-credentials', 'true'), ('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('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', '6CE875F7:1E63:532872:5514C5BC'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('last-modified', 'Fri, 27 Mar 2015 02:25:51 GMT'), ('date', 'Fri, 27 Mar 2015 02:51:40 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', '1427427963')]
|
||||
{"login":"korfuri","id":1124263,"avatar_url":"https://avatars.githubusercontent.com/u/1124263?v=3","gravatar_id":"","url":"https://api.github.com/users/korfuri","html_url":"https://github.com/korfuri","followers_url":"https://api.github.com/users/korfuri/followers","following_url":"https://api.github.com/users/korfuri/following{/other_user}","gists_url":"https://api.github.com/users/korfuri/gists{/gist_id}","starred_url":"https://api.github.com/users/korfuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/korfuri/subscriptions","organizations_url":"https://api.github.com/users/korfuri/orgs","repos_url":"https://api.github.com/users/korfuri/repos","events_url":"https://api.github.com/users/korfuri/events{/privacy}","received_events_url":"https://api.github.com/users/korfuri/received_events","type":"User","site_admin":false,"name":"Uriel Corfa","company":"","blog":"http://korfuri.fr/","location":"","email":"uriel@corfa.fr","hireable":false,"bio":null,"public_repos":12,"public_gists":0,"followers":29,"following":57,"created_at":"2011-10-13T02:27:26Z","updated_at":"2015-03-27T02:25:51Z","private_gists":0,"total_private_repos":0,"owned_private_repos":0,"disk_usage":444,"collaborators":0,"plan":{"name":"free","space":976562499,"collaborators":0,"private_repos":0}}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/openframeworks/openFrameworks/issues
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
204
|
||||
[('status', '204 No Content'), ('x-ratelimit-remaining', '4927'), ('content-length', '52085'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5e8867ffb4e7630e852b2b231f3b9cdb"'), ('date', 'Tue, 29 May 2012 19:36:57 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -492,3 +492,30 @@ class Repository(Framework.TestCase):
|
||||
stats = self.repo.get_stats_punch_card()
|
||||
self.assertEqual(stats.get(4, 12), 7)
|
||||
self.assertEqual(stats.get(6, 18), 2)
|
||||
|
||||
|
||||
class LazyRepository(Framework.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.user = self.g.get_user()
|
||||
self.repository_name = '%s/%s' % (self.user.login, "PyGithub")
|
||||
|
||||
def getLazyRepository(self):
|
||||
return self.g.get_repo(self.repository_name, lazy=True)
|
||||
|
||||
def getEagerRepository(self):
|
||||
return self.g.get_repo(self.repository_name, lazy=False)
|
||||
|
||||
def testGetIssues(self):
|
||||
lazy_repo = self.getLazyRepository()
|
||||
issues = lazy_repo.get_issues()
|
||||
eager_repo = self.getEagerRepository()
|
||||
issues2 = eager_repo.get_issues()
|
||||
self.assertListKeyEqual(issues2, id, [x for x in issues])
|
||||
|
||||
def testOwner(self):
|
||||
lazy_repo = self.getLazyRepository()
|
||||
owner = lazy_repo.owner
|
||||
eager_repo = self.getEagerRepository()
|
||||
self.assertEqual(owner, eager_repo.owner)
|
||||
|
||||
@@ -35,6 +35,10 @@ def main(argv):
|
||||
github.tests.Framework.activateRecordMode()
|
||||
argv = [arg for arg in argv if arg != "--record"]
|
||||
|
||||
if "--auth_with_token" in argv:
|
||||
github.tests.Framework.activateTokenAuthMode()
|
||||
argv = [arg for arg in argv if arg != "--auth_with_token"]
|
||||
|
||||
unittest.main(module=github.tests.AllTests, argv=argv)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user