mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Implement stargazers (issue #70)
This commit is contained in:
@@ -153,6 +153,15 @@
|
||||
"addElement": true,
|
||||
"removeElement": true
|
||||
},
|
||||
{
|
||||
"name": "starred",
|
||||
"singularName": "starred",
|
||||
"type": "Repository",
|
||||
"getList": true,
|
||||
"hasElement": true,
|
||||
"addElement": true,
|
||||
"removeElement": true
|
||||
},
|
||||
{
|
||||
"name": "following",
|
||||
"singularName": "following",
|
||||
@@ -943,6 +952,12 @@
|
||||
"type": "Repository",
|
||||
"getList": true
|
||||
},
|
||||
{
|
||||
"name": "starred",
|
||||
"singularName": "starred",
|
||||
"type": "Repository",
|
||||
"getList": true
|
||||
},
|
||||
{
|
||||
"name": "orgs",
|
||||
"singularName": "org",
|
||||
@@ -1752,6 +1767,12 @@
|
||||
"singularName": "watcher",
|
||||
"type": "NamedUser",
|
||||
"getList": true
|
||||
},
|
||||
{
|
||||
"name": "stargazers",
|
||||
"singularName": "stargazer",
|
||||
"type": "NamedUser",
|
||||
"getList": true
|
||||
}
|
||||
],
|
||||
"additionalMethods": [
|
||||
|
||||
@@ -999,6 +999,154 @@
|
||||
"name": "void"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "starred",
|
||||
"name": [
|
||||
"add",
|
||||
"to",
|
||||
"starred"
|
||||
],
|
||||
"mandatoryParameters": [
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "Repository"
|
||||
},
|
||||
"name": "starred"
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/user/starred/"
|
||||
},
|
||||
{
|
||||
"type": "identity",
|
||||
"value": [
|
||||
"starred"
|
||||
]
|
||||
}
|
||||
],
|
||||
"information": "status",
|
||||
"verb": "PUT"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": true,
|
||||
"cardinality": "scalar",
|
||||
"name": "void"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "starred",
|
||||
"name": [
|
||||
"get",
|
||||
"starred"
|
||||
],
|
||||
"mandatoryParameters": [],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/user/starred"
|
||||
}
|
||||
],
|
||||
"information": "data",
|
||||
"verb": "GET"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "list",
|
||||
"name": "Repository"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "starred",
|
||||
"name": [
|
||||
"has",
|
||||
"in",
|
||||
"starred"
|
||||
],
|
||||
"mandatoryParameters": [
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "Repository"
|
||||
},
|
||||
"name": "starred"
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/user/starred/"
|
||||
},
|
||||
{
|
||||
"type": "identity",
|
||||
"value": [
|
||||
"starred"
|
||||
]
|
||||
}
|
||||
],
|
||||
"information": "status",
|
||||
"verb": "GET"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": true,
|
||||
"cardinality": "scalar",
|
||||
"name": "bool"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "starred",
|
||||
"name": [
|
||||
"remove",
|
||||
"from",
|
||||
"starred"
|
||||
],
|
||||
"mandatoryParameters": [
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "Repository"
|
||||
},
|
||||
"name": "starred"
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/user/starred/"
|
||||
},
|
||||
{
|
||||
"type": "identity",
|
||||
"value": [
|
||||
"starred"
|
||||
]
|
||||
}
|
||||
],
|
||||
"information": "status",
|
||||
"verb": "DELETE"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": true,
|
||||
"cardinality": "scalar",
|
||||
"name": "void"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "following",
|
||||
"name": [
|
||||
@@ -5344,6 +5492,37 @@
|
||||
"name": "Repository"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "starred",
|
||||
"name": [
|
||||
"get",
|
||||
"starred"
|
||||
],
|
||||
"mandatoryParameters": [],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "attribute",
|
||||
"value": [
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/starred"
|
||||
}
|
||||
],
|
||||
"information": "data",
|
||||
"verb": "GET"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "list",
|
||||
"name": "Repository"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "orgs",
|
||||
"name": [
|
||||
@@ -10199,6 +10378,37 @@
|
||||
"name": "NamedUser"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "stargazers",
|
||||
"name": [
|
||||
"get",
|
||||
"stargazers"
|
||||
],
|
||||
"mandatoryParameters": [],
|
||||
"request": {
|
||||
"url": [
|
||||
{
|
||||
"type": "attribute",
|
||||
"value": [
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "constant",
|
||||
"value": "/stargazers"
|
||||
}
|
||||
],
|
||||
"information": "data",
|
||||
"verb": "GET"
|
||||
},
|
||||
"isMutation": false,
|
||||
"optionalParameters": [],
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "list",
|
||||
"name": "NamedUser"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": "events",
|
||||
"name": [
|
||||
|
||||
@@ -404,7 +404,7 @@ API `/repos/:user/:repo/readme`
|
||||
|
||||
API `/repos/:user/:repo/stargazers`
|
||||
===================================
|
||||
* GET: (TODO)
|
||||
* GET: `Repository.get_stargazers`
|
||||
|
||||
API `/repos/:user/:repo/statuses/:sha`
|
||||
======================================
|
||||
@@ -500,13 +500,13 @@ API `/user/repos`
|
||||
|
||||
API `/user/starred`
|
||||
===================
|
||||
* GET: (TODO)
|
||||
* GET: `AuthenticatedUser.get_starred`
|
||||
|
||||
API `/user/starred/:user/:repo`
|
||||
===============================
|
||||
* GET: (TODO)
|
||||
* PUT: (TODO)
|
||||
* DELETE: (TODO)
|
||||
* GET: `AuthenticatedUser.has_in_starred`
|
||||
* PUT: `AuthenticatedUser.add_to_starred`
|
||||
* DELETE: `AuthenticatedUser.remove_from_starred`
|
||||
|
||||
API `/user/subscriptions`
|
||||
=========================
|
||||
@@ -575,7 +575,7 @@ API `/users/:user/repos`
|
||||
|
||||
API `/users/:user/starred`
|
||||
==========================
|
||||
* GET: (TODO)
|
||||
* GET: `NamedUser.get_starred`
|
||||
|
||||
API `/users/:user/subscriptions`
|
||||
================================
|
||||
|
||||
@@ -180,6 +180,16 @@ Repos
|
||||
* `sort`: string
|
||||
* `direction`: string
|
||||
|
||||
Starred
|
||||
-------
|
||||
* `add_to_starred( starred )`
|
||||
* `starred`: `Repository`
|
||||
* `get_starred()`: iterator of `Repository`
|
||||
* `has_in_starred( starred )`: bool
|
||||
* `starred`: `Repository`
|
||||
* `remove_from_starred( starred )`
|
||||
* `starred`: `Repository`
|
||||
|
||||
Watched
|
||||
-------
|
||||
* `add_to_watched( watched )`
|
||||
@@ -815,6 +825,10 @@ Repos
|
||||
* `get_repos( [type] )`: iterator of `Repository`
|
||||
* `type`: string
|
||||
|
||||
Starred
|
||||
-------
|
||||
* `get_starred()`: iterator of `Repository`
|
||||
|
||||
Watched
|
||||
-------
|
||||
* `get_watched()`: iterator of `Repository`
|
||||
@@ -1293,6 +1307,10 @@ Pulls
|
||||
* `get_pulls( [state] )`: iterator of `PullRequest`
|
||||
* `state`: string
|
||||
|
||||
Stargazers
|
||||
----------
|
||||
* `get_stargazers()`: iterator of `NamedUser`
|
||||
|
||||
Tags
|
||||
----
|
||||
* `get_tags()`: iterator of `Tag`
|
||||
|
||||
@@ -173,6 +173,15 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
None
|
||||
)
|
||||
|
||||
def add_to_starred( self, starred ):
|
||||
assert isinstance( starred, Repository.Repository ), starred
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"PUT",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def add_to_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
@@ -496,6 +505,20 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_starred( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
"/user/starred",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
Repository.Repository,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_starred_gists( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
@@ -534,6 +557,16 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def has_in_starred( self, starred ):
|
||||
assert isinstance( starred, Repository.Repository ), starred
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
"GET",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def has_in_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
@@ -563,6 +596,15 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
None
|
||||
)
|
||||
|
||||
def remove_from_starred( self, starred ):
|
||||
assert isinstance( starred, Repository.Repository ), starred
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"DELETE",
|
||||
"/user/starred/" + starred._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def remove_from_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
|
||||
@@ -314,6 +314,20 @@ class NamedUser( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_starred( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self.url + "/starred",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
Repository.Repository,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_watched( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
|
||||
@@ -964,6 +964,20 @@ class Repository( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_stargazers( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self.url + "/stargazers",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
NamedUser.NamedUser,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_tags( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
|
||||
@@ -90,6 +90,15 @@ class AuthenticatedUser( Framework.TestCase ):
|
||||
self.user.add_to_watched( gitflow )
|
||||
self.assertEqual( self.user.has_in_watched( gitflow ), True )
|
||||
|
||||
def testStarring( self ):
|
||||
gitflow = self.g.get_user( "nvie" ).get_repo( "gitflow" )
|
||||
self.assertListKeyEqual( self.user.get_starred(), lambda r: r.name, [ "git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "amaunet", "django", "django", "moviePlanning", "folly" ] )
|
||||
self.assertEqual( self.user.has_in_starred( gitflow ), True )
|
||||
self.user.remove_from_starred( gitflow )
|
||||
self.assertEqual( self.user.has_in_starred( gitflow ), False )
|
||||
self.user.add_to_starred( gitflow )
|
||||
self.assertEqual( self.user.has_in_starred( gitflow ), True )
|
||||
|
||||
def testGetAuthorizations( self ):
|
||||
self.assertListKeyEqual( self.user.get_authorizations(), lambda a: a.id, [ 372294 ] )
|
||||
|
||||
|
||||
@@ -111,6 +111,9 @@ class NamedUser( Framework.TestCase ):
|
||||
def testGetWatched( self ):
|
||||
self.assertListKeyEqual( self.user.get_watched(), lambda r: r.name, [ "git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "PyGithub", "django", "django", "TestPyGithub" ] )
|
||||
|
||||
def testGetStarred( self ):
|
||||
self.assertListKeyEqual( self.user.get_starred(), lambda r: r.name, [ "git", "boost.php", "capistrano", "boost.perl", "git-subtree", "git-hg", "homebrew", "celtic_knot", "twisted-intro", "markup", "hub", "gitflow", "murder", "boto", "agit", "d3", "pygit2", "git-pulls", "django_mathlatex", "scrumblr", "developer.github.com", "python-github3", "PlantUML", "bootstrap", "drawnby", "django-socketio", "django-realtime", "playground", "BozoCrack", "FatherBeaver", "amaunet", "django", "django", "moviePlanning", "folly" ] )
|
||||
|
||||
def testGetEvents( self ):
|
||||
self.assertListKeyBegin( self.user.get_events(), lambda e: e.type, [ "GistEvent", "IssueCommentEvent", "PushEvent", "IssuesEvent" ] )
|
||||
|
||||
|
||||
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
@@ -322,6 +322,9 @@ class Repository( Framework.TestCase ):
|
||||
def testGetWatchers( self ):
|
||||
self.assertListKeyEqual( self.repo.get_watchers(), lambda u: u.login, [ "Stals", "att14", "jardon-u", "huxley", "mikofski", "L42y", "fanzeyi", "abersager", "waylan", "adericbourg", "tallforasmurf", "pvicente", "roskakori", "michaelpedersen", "BeaverSoftware" ] )
|
||||
|
||||
def testGetStargazers( self ):
|
||||
self.assertListKeyEqual( self.repo.get_stargazers(), lambda u: u.login, [ "Stals", "att14", "jardon-u", "huxley", "mikofski", "L42y", "fanzeyi", "abersager", "waylan", "adericbourg", "tallforasmurf", "pvicente", "roskakori", "michaelpedersen", "stefanfoulis", "equus12", "JuRogn", "joshmoore", "jsilter", "dasapich", "ritratt", "hcilab", "vxnick", "pmuilu", "herlo", "malexw", "ahmetvurgun", "PengGu", "cosmin", "Swop", "kennethreitz", "bryandyck", "jason2506", "zsiciarz", "waawal", "gregorynicholas", "sente", "richmiller55", "thouis", "mazubieta", "michaelhood", "engie", "jtriley", "oangeor", "coryking", "noddi", "alejo8591", "omab", "Carreau", "bilderbuchi", "schwa", "rlerallut", "PengHub", "zoek1", "xobb1t", "notgary", "hattya", "ZebtinRis", "aaronhall", "youngsterxyf", "ailling", "gregwjacobs", "n0rmrx", "awylie", "firstthumb", "joshbrand", "berndca" ] )
|
||||
|
||||
def testCreatePull( self ):
|
||||
pull = self.repo.create_pull( "Pull request created by PyGithub", "Body of the pull request", "topic/RewriteWithGeneratedCode", "BeaverSoftware:master" )
|
||||
self.assertEqual( pull.id, 1436215 )
|
||||
|
||||
Reference in New Issue
Block a user