Implement assignees (issue #68)

This commit is contained in:
Vincent Jacques
2012-09-08 01:16:14 +02:00
parent 76c499df51
commit 696e198c18
7 changed files with 173 additions and 2 deletions
@@ -1403,6 +1403,13 @@
"addElement": true,
"removeElement": true
},
{
"name": "assignees",
"singularName": "assignee",
"type": "NamedUser",
"getList": true,
"hasElement": true
},
{
"name": "comments",
"singularName": "comment",
@@ -7995,6 +7995,84 @@
"name": "void"
}
},
{
"group": "assignees",
"name": [
"get",
"assignees"
],
"mandatoryParameters": [],
"request": {
"url": [
{
"type": "attribute",
"value": [
"url"
]
},
{
"type": "constant",
"value": "/assignees"
}
],
"information": "data",
"verb": "GET"
},
"isMutation": false,
"optionalParameters": [],
"type": {
"simple": false,
"cardinality": "list",
"name": "NamedUser"
}
},
{
"group": "assignees",
"name": [
"has",
"in",
"assignees"
],
"mandatoryParameters": [
{
"type": {
"simple": false,
"cardinality": "scalar",
"name": "NamedUser"
},
"name": "assignee"
}
],
"request": {
"url": [
{
"type": "attribute",
"value": [
"url"
]
},
{
"type": "constant",
"value": "/assignees/"
},
{
"type": "identity",
"value": [
"assignee"
]
}
],
"information": "status",
"verb": "GET"
},
"isMutation": false,
"optionalParameters": [],
"type": {
"simple": true,
"cardinality": "scalar",
"name": "bool"
}
},
{
"group": "comments",
"name": [
+2 -2
View File
@@ -139,11 +139,11 @@ API `/repos/:user/:repo/:archive_format/:ref`
API `/repos/:user/:repo/assignees`
==================================
* GET: (TODO)
* GET: `Repository.get_assignees`
API `/repos/:user/:repo/assignees/:assignee`
============================================
* GET: (TODO)
* GET: `Repository.has_in_assignees`
API `/repos/:user/:repo/branches`
=================================
+6
View File
@@ -1083,6 +1083,12 @@ Comparison
* `base`: string
* `head`: string
Assignees
---------
* `get_assignees()`: iterator of `NamedUser`
* `has_in_assignees( assignee )`: bool
* `assignee`: `NamedUser`
Branches
--------
* `get_branches()`: iterator of `Branch`
+24
View File
@@ -497,6 +497,20 @@ class Repository( GithubObject.GithubObject ):
)
self._useAttributes( data )
def get_assignees( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/assignees",
None,
None
)
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
headers,
data
)
def get_branches( self ):
headers, data = self._requester.requestAndCheck(
"GET",
@@ -992,6 +1006,16 @@ class Repository( GithubObject.GithubObject ):
data
)
def has_in_assignees( self, assignee ):
assert isinstance( assignee, NamedUser.NamedUser ), assignee
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/assignees/" + assignee._identity,
None,
None
)
return status == 204
def has_in_collaborators( self, collaborator ):
assert isinstance( collaborator, NamedUser.NamedUser ), collaborator
status, headers, data = self._requester.requestRaw(
@@ -0,0 +1,45 @@
https GET api.github.com None /users/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
200
[('status', '200 OK'), ('content-length', '559'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4997'), ('server', 'nginx/1.0.13'), ('last-modified', 'Sun, 16 Oct 2011 14:37:52 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"bf612afdcca3f4967bc08bb5eeebc443"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Fri, 07 Sep 2012 23:12:25 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"public_gists":0,"type":"User","login":"Lyloa","following":0,"location":"Paris","bio":null,"avatar_url":"https://secure.gravatar.com/avatar/1517ed584458ccf83e03f5d77d9699d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","public_repos":0,"created_at":"2011-10-16T14:36:46Z","email":"nyu@lyloa.net","gravatar_id":"1517ed584458ccf83e03f5d77d9699d7","url":"https://api.github.com/users/Lyloa","name":"Lyloa","company":null,"followers":1,"html_url":"https://github.com/Lyloa","id":1131432,"blog":null,"hireable":false}
https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '806'), ('server', 'nginx/1.0.13'), ('last-modified', 'Wed, 05 Sep 2012 15:03:24 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"350294b94004d4bb252b6a432baa5744"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Fri, 07 Sep 2012 23:12:25 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"User","company":"Criteo","plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"followers":13,"public_gists":3,"private_gists":5,"disk_usage":14640,"following":28,"html_url":"https://github.com/jacquev6","location":"Paris, France","total_private_repos":5,"blog":"http://vincent-jacques.net","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","owned_private_repos":5,"collaborators":0,"bio":"","login":"jacquev6","name":"Vincent Jacques","public_repos":11,"created_at":"2010-07-09T06:10:06Z","id":327146,"email":"vincent@vincent-jacques.net"}
https GET api.github.com None /repos/jacquev6/PyGithub/assignees/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4995'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:26 GMT')]
https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
404
[('status', '404 Not Found'), ('content-length', '23'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-remaining', '4994'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:26 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"message":"Not Found"}
https PUT api.github.com None /repos/jacquev6/PyGithub/collaborators/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4993'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:27 GMT')]
https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4992'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:27 GMT')]
https GET api.github.com None /repos/jacquev6/PyGithub/assignees {'Authorization': 'Basic login_and_password_removed'} null
200
[('status', '200 OK'), ('content-length', '600'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4991'), ('server', 'nginx/1.0.13'), ('last-modified', 'Wed, 05 Sep 2012 15:03:24 GMT'), ('connection', 'keep-alive'), ('etag', '"350294b94004d4bb252b6a432baa5744"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Fri, 07 Sep 2012 23:12:28 GMT'), ('x-github-media-type', 'github.beta; format=json'), ('content-type', 'application/json; charset=utf-8')]
[{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},{"avatar_url":"https://secure.gravatar.com/avatar/1517ed584458ccf83e03f5d77d9699d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","url":"https://api.github.com/users/Lyloa","gravatar_id":"1517ed584458ccf83e03f5d77d9699d7","login":"Lyloa","id":1131432}]
https DELETE api.github.com None /repos/jacquev6/PyGithub/collaborators/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4990'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:28 GMT')]
https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
404
[('status', '404 Not Found'), ('x-ratelimit-remaining', '4989'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('content-length', '23'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Fri, 07 Sep 2012 23:12:29 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"message":"Not Found"}
+11
View File
@@ -339,3 +339,14 @@ class Repository( Framework.TestCase ):
def testLegacySearchIssues( self ):
self.assertListKeyEqual( self.repo.legacy_search_issues( "open", "search" ), lambda i: i.title, [ "Support new Search API" ] )
def testAssignees( self ):
lyloa = self.g.get_user( "Lyloa" )
jacquev6 = self.g.get_user( "jacquev6" )
self.assertTrue( self.repo.has_in_assignees( jacquev6 ) )
self.assertFalse( self.repo.has_in_assignees( lyloa ) )
self.repo.add_to_collaborators( lyloa )
self.assertTrue( self.repo.has_in_assignees( lyloa ) )
self.assertListKeyEqual( self.repo.get_assignees(), lambda u: u.login, [ "jacquev6", "Lyloa" ] )
self.repo.remove_from_collaborators( lyloa )
self.assertFalse( self.repo.has_in_assignees( lyloa ) )