mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Merge branch 'topic/ExposeRawData' into develop
This commit is contained in:
@@ -27,7 +27,7 @@ import github.Event
|
||||
import github.Authorization
|
||||
|
||||
|
||||
class AuthenticatedUser(github.GithubObject.GithubObject):
|
||||
class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents AuthenticatedUsers as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.AuthorizationApplication
|
||||
|
||||
|
||||
class Authorization(github.GithubObject.GithubObject):
|
||||
class Authorization(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Authorizations as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class AuthorizationApplication(github.GithubObject.GithubObject):
|
||||
class AuthorizationApplication(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents AuthorizationApplications as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.Commit
|
||||
|
||||
|
||||
class Branch(github.GithubObject.BasicGithubObject):
|
||||
class Branch(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Branchs as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import github.CommitStats
|
||||
import github.CommitComment
|
||||
|
||||
|
||||
class Commit(github.GithubObject.GithubObject):
|
||||
class Commit(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Commits as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class CommitComment(github.GithubObject.GithubObject):
|
||||
class CommitComment(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents CommitComments as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class CommitStats(github.GithubObject.BasicGithubObject):
|
||||
class CommitStats(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents CommitStatss as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class CommitStatus(github.GithubObject.BasicGithubObject):
|
||||
class CommitStatus(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents CommitStatuss as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ import github.Commit
|
||||
import github.File
|
||||
|
||||
|
||||
class Comparison(github.GithubObject.GithubObject):
|
||||
class Comparison(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Comparisons as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class ContentFile(github.GithubObject.GithubObject):
|
||||
class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents ContentFiles as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class Download(github.GithubObject.GithubObject):
|
||||
class Download(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Downloads as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import github.Repository
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class Event(github.GithubObject.BasicGithubObject):
|
||||
class Event(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Events as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class File(github.GithubObject.BasicGithubObject):
|
||||
class File(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Files as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import github.GistFile
|
||||
import github.GistHistoryState
|
||||
|
||||
|
||||
class Gist(github.GithubObject.GithubObject):
|
||||
class Gist(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Gists as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class GistComment(github.GithubObject.GithubObject):
|
||||
class GistComment(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GistComments as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GistFile(github.GithubObject.BasicGithubObject):
|
||||
class GistFile(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents GistFiles as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ import github.NamedUser
|
||||
import github.CommitStats
|
||||
|
||||
|
||||
class GistHistoryState(github.GithubObject.GithubObject):
|
||||
class GistHistoryState(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GistHistoryStates as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GitAuthor(github.GithubObject.BasicGithubObject):
|
||||
class GitAuthor(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents GitAuthors as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GitBlob(github.GithubObject.GithubObject):
|
||||
class GitBlob(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitBlobs as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import github.GitAuthor
|
||||
import github.GitTree
|
||||
|
||||
|
||||
class GitCommit(github.GithubObject.GithubObject):
|
||||
class GitCommit(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitCommits as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GitObject(github.GithubObject.BasicGithubObject):
|
||||
class GitObject(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents GitObjects as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.GitObject
|
||||
|
||||
|
||||
class GitRef(github.GithubObject.GithubObject):
|
||||
class GitRef(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitRefs as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import github.GitAuthor
|
||||
import github.GitObject
|
||||
|
||||
|
||||
class GitTag(github.GithubObject.GithubObject):
|
||||
class GitTag(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitTags as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.GitTreeElement
|
||||
|
||||
|
||||
class GitTree(github.GithubObject.GithubObject):
|
||||
class GitTree(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents GitTrees as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GitTreeElement(github.GithubObject.BasicGithubObject):
|
||||
class GitTreeElement(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents GitTreeElements as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+26
-5
@@ -24,11 +24,23 @@ class _NotSetType:
|
||||
NotSet = _NotSetType()
|
||||
|
||||
|
||||
class BasicGithubObject(object):
|
||||
class GithubObject(object):
|
||||
def __init__(self, requester, attributes, completed):
|
||||
self._requester = requester
|
||||
self._initAttributes()
|
||||
self._storeAndUseAttributes(attributes)
|
||||
|
||||
def _storeAndUseAttributes(self, attributes):
|
||||
self._useAttributes(attributes)
|
||||
self._rawData = attributes
|
||||
|
||||
@property
|
||||
def raw_data(self):
|
||||
"""
|
||||
:type: dict
|
||||
"""
|
||||
self._completeIfNeeded()
|
||||
return self._rawData
|
||||
|
||||
@staticmethod
|
||||
def _parentUrl(url):
|
||||
@@ -53,13 +65,22 @@ class BasicGithubObject(object):
|
||||
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
|
||||
class GithubObject(BasicGithubObject):
|
||||
class NonCompletableGithubObject(GithubObject):
|
||||
def _completeIfNeeded(self):
|
||||
pass
|
||||
|
||||
|
||||
class CompletableGithubObject(GithubObject):
|
||||
def __init__(self, requester, attributes, completed):
|
||||
BasicGithubObject.__init__(self, requester, attributes, completed)
|
||||
GithubObject.__init__(self, requester, attributes, completed)
|
||||
self.__completed = completed
|
||||
|
||||
def _completeIfNotSet(self, value):
|
||||
if not self.__completed and value is NotSet:
|
||||
if value is NotSet:
|
||||
self._completeIfNeeded()
|
||||
|
||||
def _completeIfNeeded(self):
|
||||
if not self.__completed:
|
||||
self.__complete()
|
||||
|
||||
def __complete(self):
|
||||
@@ -69,5 +90,5 @@ class GithubObject(BasicGithubObject):
|
||||
None,
|
||||
None
|
||||
)
|
||||
self._useAttributes(data)
|
||||
self._storeAndUseAttributes(data)
|
||||
self.__completed = True
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class GitignoreTemplate(github.GithubObject.BasicGithubObject):
|
||||
class GitignoreTemplate(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents GitignoreTemplates as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.HookResponse
|
||||
|
||||
|
||||
class Hook(github.GithubObject.GithubObject):
|
||||
class Hook(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Hooks as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class HookDescription(github.GithubObject.BasicGithubObject):
|
||||
class HookDescription(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents HookDescriptions as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class HookResponse(github.GithubObject.BasicGithubObject):
|
||||
class HookResponse(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents HookResponses as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import github.IssueComment
|
||||
import github.IssuePullRequest
|
||||
|
||||
|
||||
class Issue(github.GithubObject.GithubObject):
|
||||
class Issue(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Issues as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class IssueComment(github.GithubObject.GithubObject):
|
||||
class IssueComment(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents IssueComments as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ import github.Issue
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class IssueEvent(github.GithubObject.GithubObject):
|
||||
class IssueEvent(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents IssueEvents as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class IssuePullRequest(github.GithubObject.BasicGithubObject):
|
||||
class IssuePullRequest(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents IssuePullRequests as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import urllib
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class Label(github.GithubObject.GithubObject):
|
||||
class Label(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Labels as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -278,3 +278,13 @@ class Github(object):
|
||||
None
|
||||
)
|
||||
return GitignoreTemplate.GitignoreTemplate(self.__requester, attributes, completed=True)
|
||||
|
||||
def create_from_raw_data(self, klass, raw_data):
|
||||
"""
|
||||
Creates an object from raw_data previously obtained by ``myObject.raw_data``
|
||||
|
||||
:param klass: the class of the object to create
|
||||
:param raw_data: dict
|
||||
:rtype: instance of class ``klass``
|
||||
"""
|
||||
return klass(self.__requester, raw_data, completed=True)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import github.NamedUser
|
||||
import github.Label
|
||||
|
||||
|
||||
class Milestone(github.GithubObject.GithubObject):
|
||||
class Milestone(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Milestones as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import github.Organization
|
||||
import github.Event
|
||||
|
||||
|
||||
class NamedUser(github.GithubObject.GithubObject):
|
||||
class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents NamedUsers as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@ import github.Repository
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class Organization(github.GithubObject.GithubObject):
|
||||
class Organization(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Organizations as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class Permissions(github.GithubObject.BasicGithubObject):
|
||||
class Permissions(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Permissionss as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class Plan(github.GithubObject.BasicGithubObject):
|
||||
class Plan(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Plans as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -25,7 +25,7 @@ import github.IssueComment
|
||||
import github.Commit
|
||||
|
||||
|
||||
class PullRequest(github.GithubObject.GithubObject):
|
||||
class PullRequest(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents PullRequests as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class PullRequestComment(github.GithubObject.GithubObject):
|
||||
class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents PullRequestComments as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class PullRequestMergeStatus(github.GithubObject.BasicGithubObject):
|
||||
class PullRequestMergeStatus(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents PullRequestMergeStatuss as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ import github.Repository
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class PullRequestPart(github.GithubObject.BasicGithubObject):
|
||||
class PullRequestPart(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents PullRequestParts as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -47,7 +47,7 @@ import github.Event
|
||||
import github.Legacy
|
||||
|
||||
|
||||
class Repository(github.GithubObject.GithubObject):
|
||||
class Repository(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Repositorys as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class RepositoryKey(github.GithubObject.GithubObject):
|
||||
class RepositoryKey(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents RepositoryKeys as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
def __init__(self, requester, attributes, completed, repoUrl):
|
||||
github.GithubObject.GithubObject.__init__(self, requester, attributes, completed)
|
||||
github.GithubObject.CompletableGithubObject.__init__(self, requester, attributes, completed)
|
||||
self.__repoUrl = repoUrl
|
||||
|
||||
@property
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import github.GithubObject
|
||||
import github.Commit
|
||||
|
||||
|
||||
class Tag(github.GithubObject.BasicGithubObject):
|
||||
class Tag(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents Tags as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import github.Repository
|
||||
import github.NamedUser
|
||||
|
||||
|
||||
class Team(github.GithubObject.GithubObject):
|
||||
class Team(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Teams as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class UserKey(github.GithubObject.GithubObject):
|
||||
class UserKey(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents UserKeys as returned for example by http://developer.github.com/v3/todo
|
||||
"""
|
||||
|
||||
@@ -54,6 +54,7 @@ from PaginatedList import *
|
||||
from Exceptions import *
|
||||
from Enterprise import *
|
||||
from Logging_ import *
|
||||
from RawData import *
|
||||
|
||||
from Issue33 import *
|
||||
from Issue50 import *
|
||||
|
||||
@@ -23,7 +23,7 @@ class Issue139(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issu
|
||||
self.user = self.g.get_user().get_repo("PyGithub").get_issue(139).user
|
||||
|
||||
def testCompletion(self):
|
||||
self.assertFalse(self.user._GithubObject__completed)
|
||||
self.assertFalse(self.user._CompletableGithubObject__completed)
|
||||
self.assertEqual(self.user.name, "Ian Ozsvald")
|
||||
self.assertTrue(self.user._GithubObject__completed)
|
||||
self.assertTrue(self.user._CompletableGithubObject__completed)
|
||||
self.assertEqual(self.user.plan, None)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Vincent Jacques
|
||||
# vincent@vincent-jacques.net
|
||||
|
||||
# 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
|
||||
|
||||
import github.NamedUser
|
||||
|
||||
class RawData(Framework.TestCase):
|
||||
jacquev6RawData = {
|
||||
u'disk_usage': 13812,
|
||||
u'private_gists': 5,
|
||||
u'public_repos': 21,
|
||||
u'subscriptions_url': u'https://api.github.com/users/jacquev6/subscriptions',
|
||||
u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225',
|
||||
u'hireable': False,
|
||||
u'id': 327146,
|
||||
u'followers_url': u'https://api.github.com/users/jacquev6/followers',
|
||||
u'following_url': u'https://api.github.com/users/jacquev6/following',
|
||||
u'collaborators': 1,
|
||||
u'total_private_repos': 4,
|
||||
u'blog': u'http://vincent-jacques.net',
|
||||
u'followers': 22,
|
||||
u'location': u'Paris, France',
|
||||
u'type': u'User',
|
||||
u'email': u'vincent@vincent-jacques.net',
|
||||
u'bio': u'',
|
||||
u'gists_url': u'https://api.github.com/users/jacquev6/gists{/gist_id}',
|
||||
u'owned_private_repos': 4,
|
||||
u'company': u'Criteo',
|
||||
u'events_url': u'https://api.github.com/users/jacquev6/events{/privacy}',
|
||||
u'html_url': u'https://github.com/jacquev6',
|
||||
u'updated_at': u'2013-03-12T22:13:32Z',
|
||||
u'plan': {
|
||||
u'collaborators': 1,
|
||||
u'name': u'micro',
|
||||
u'private_repos': 5,
|
||||
u'space': 614400,
|
||||
},
|
||||
u'received_events_url': u'https://api.github.com/users/jacquev6/received_events',
|
||||
u'starred_url': u'https://api.github.com/users/jacquev6/starred{/owner}{/repo}',
|
||||
u'public_gists': 2,
|
||||
u'name': u'Vincent Jacques',
|
||||
u'organizations_url': u'https://api.github.com/users/jacquev6/orgs',
|
||||
u'url': u'https://api.github.com/users/jacquev6',
|
||||
u'created_at': u'2010-07-09T06:10:06Z',
|
||||
u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png',
|
||||
u'repos_url': u'https://api.github.com/users/jacquev6/repos',
|
||||
u'following': 38,
|
||||
u'login': u'jacquev6',
|
||||
}
|
||||
|
||||
planRawData = {
|
||||
u'collaborators': 1,
|
||||
u'name': u'micro',
|
||||
u'private_repos': 5,
|
||||
u'space': 614400,
|
||||
}
|
||||
|
||||
def testCompletedObject(self):
|
||||
user = self.g.get_user("jacquev6")
|
||||
self.assertTrue(user._CompletableGithubObject__completed)
|
||||
self.assertEqual(user.raw_data, RawData.jacquev6RawData)
|
||||
|
||||
def testNotYetCompletedObject(self):
|
||||
user = self.g.get_user().get_repo("PyGithub").owner
|
||||
self.assertFalse(user._CompletableGithubObject__completed)
|
||||
self.assertEqual(user.raw_data, RawData.jacquev6RawData)
|
||||
self.assertTrue(user._CompletableGithubObject__completed)
|
||||
|
||||
def testNonCompletableObject(self):
|
||||
plan = self.g.get_user().plan
|
||||
self.assertEqual(plan.raw_data, RawData.planRawData)
|
||||
|
||||
def testCreateObjectFromRawData(self):
|
||||
user = self.g.create_from_raw_data(github.NamedUser.NamedUser, RawData.jacquev6RawData)
|
||||
self.assertEqual(user._CompletableGithubObject__completed, True)
|
||||
self.assertEqual(user.name, "Vincent Jacques")
|
||||
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:30 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5}
|
||||
|
||||
https GET api.github.com None /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '4656'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"id":3544490,"name":"PyGithub","full_name":"jacquev6/PyGithub","owner":{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User"},"private":false,"html_url":"https://github.com/jacquev6/PyGithub","description":"Python library implementing the full Github API v3","fork":false,"url":"https://api.github.com/repos/jacquev6/PyGithub","forks_url":"https://api.github.com/repos/jacquev6/PyGithub/forks","keys_url":"https://api.github.com/repos/jacquev6/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/PyGithub/teams","hooks_url":"https://api.github.com/repos/jacquev6/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/PyGithub/events","assignees_url":"https://api.github.com/repos/jacquev6/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/PyGithub/tags{/tag}","blobs_url":"https://api.github.com/repos/jacquev6/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/PyGithub/languages","stargazers_url":"https://api.github.com/repos/jacquev6/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/PyGithub/subscription","commits_url":"https://api.github.com/repos/jacquev6/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/{number}","contents_url":"https://api.github.com/repos/jacquev6/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/PyGithub/merges","archive_url":"https://api.github.com/repos/jacquev6/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/PyGithub/downloads","issues_url":"https://api.github.com/repos/jacquev6/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/PyGithub/labels{/name}","created_at":"2012-02-25T12:53:47Z","updated_at":"2013-03-12T22:13:32Z","pushed_at":"2013-03-12T09:25:23Z","git_url":"git://github.com/jacquev6/PyGithub.git","ssh_url":"git@github.com:jacquev6/PyGithub.git","clone_url":"https://github.com/jacquev6/PyGithub.git","svn_url":"https://github.com/jacquev6/PyGithub","homepage":"http://jacquev6.github.com/PyGithub","size":416,"watchers_count":167,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":47,"mirror_url":null,"open_issues_count":13,"forks":47,"open_issues":13,"watchers":167,"master_branch":"master","default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"network_count":47}
|
||||
|
||||
https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:32 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5}
|
||||
|
||||
Reference in New Issue
Block a user