Skip to content
This repository
Browse code

Implement assignees (issue #68)

  • Loading branch information...
commit 696e198c185f03dbc1bf9f401a8f01c458bd3ccf 1 parent 76c499d
Vincent Jacques authored September 08, 2012
7  codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json
@@ -1404,6 +1404,13 @@
1404 1404
                     "removeElement": true
1405 1405
                 },
1406 1406
                 {
  1407
+                    "name": "assignees",
  1408
+                    "singularName": "assignee",
  1409
+                    "type": "NamedUser",
  1410
+                    "getList": true,
  1411
+                    "hasElement": true
  1412
+                },
  1413
+                {
1407 1414
                     "name": "comments",
1408 1415
                     "singularName": "comment",
1409 1416
                     "type": "CommitComment",
78  codegen/JsonDescriptionOfGithubApiV3/description.normalized.json
@@ -7996,6 +7996,84 @@
7996 7996
                     }
7997 7997
                 }, 
7998 7998
                 {
  7999
+                    "group": "assignees", 
  8000
+                    "name": [
  8001
+                        "get", 
  8002
+                        "assignees"
  8003
+                    ], 
  8004
+                    "mandatoryParameters": [], 
  8005
+                    "request": {
  8006
+                        "url": [
  8007
+                            {
  8008
+                                "type": "attribute", 
  8009
+                                "value": [
  8010
+                                    "url"
  8011
+                                ]
  8012
+                            }, 
  8013
+                            {
  8014
+                                "type": "constant", 
  8015
+                                "value": "/assignees"
  8016
+                            }
  8017
+                        ], 
  8018
+                        "information": "data", 
  8019
+                        "verb": "GET"
  8020
+                    }, 
  8021
+                    "isMutation": false, 
  8022
+                    "optionalParameters": [], 
  8023
+                    "type": {
  8024
+                        "simple": false, 
  8025
+                        "cardinality": "list", 
  8026
+                        "name": "NamedUser"
  8027
+                    }
  8028
+                }, 
  8029
+                {
  8030
+                    "group": "assignees", 
  8031
+                    "name": [
  8032
+                        "has", 
  8033
+                        "in", 
  8034
+                        "assignees"
  8035
+                    ], 
  8036
+                    "mandatoryParameters": [
  8037
+                        {
  8038
+                            "type": {
  8039
+                                "simple": false, 
  8040
+                                "cardinality": "scalar", 
  8041
+                                "name": "NamedUser"
  8042
+                            }, 
  8043
+                            "name": "assignee"
  8044
+                        }
  8045
+                    ], 
  8046
+                    "request": {
  8047
+                        "url": [
  8048
+                            {
  8049
+                                "type": "attribute", 
  8050
+                                "value": [
  8051
+                                    "url"
  8052
+                                ]
  8053
+                            }, 
  8054
+                            {
  8055
+                                "type": "constant", 
  8056
+                                "value": "/assignees/"
  8057
+                            }, 
  8058
+                            {
  8059
+                                "type": "identity", 
  8060
+                                "value": [
  8061
+                                    "assignee"
  8062
+                                ]
  8063
+                            }
  8064
+                        ], 
  8065
+                        "information": "status", 
  8066
+                        "verb": "GET"
  8067
+                    }, 
  8068
+                    "isMutation": false, 
  8069
+                    "optionalParameters": [], 
  8070
+                    "type": {
  8071
+                        "simple": true, 
  8072
+                        "cardinality": "scalar", 
  8073
+                        "name": "bool"
  8074
+                    }
  8075
+                }, 
  8076
+                {
7999 8077
                     "group": "comments", 
8000 8078
                     "name": [
8001 8079
                         "get", 
4  doc/ReferenceOfApis.md
Source Rendered
@@ -139,11 +139,11 @@ API `/repos/:user/:repo/:archive_format/:ref`
139 139
 
140 140
 API `/repos/:user/:repo/assignees`
141 141
 ==================================
142  
-* GET: (TODO)
  142
+* GET: `Repository.get_assignees`
143 143
 
144 144
 API `/repos/:user/:repo/assignees/:assignee`
145 145
 ============================================
146  
-* GET: (TODO)
  146
+* GET: `Repository.has_in_assignees`
147 147
 
148 148
 API `/repos/:user/:repo/branches`
149 149
 =================================
6  doc/ReferenceOfClasses.md
Source Rendered
@@ -1083,6 +1083,12 @@ Comparison
1083 1083
     * `base`: string
1084 1084
     * `head`: string
1085 1085
 
  1086
+Assignees
  1087
+---------
  1088
+* `get_assignees()`: iterator of `NamedUser`
  1089
+* `has_in_assignees( assignee )`: bool
  1090
+    * `assignee`: `NamedUser`
  1091
+
1086 1092
 Branches
1087 1093
 --------
1088 1094
 * `get_branches()`: iterator of `Branch`
24  github/Repository.py
@@ -497,6 +497,20 @@ def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject
497 497
         )
498 498
         self._useAttributes( data )
499 499
 
  500
+    def get_assignees( self ):
  501
+        headers, data = self._requester.requestAndCheck(
  502
+            "GET",
  503
+            self.url + "/assignees",
  504
+            None,
  505
+            None
  506
+        )
  507
+        return PaginatedList.PaginatedList(
  508
+            NamedUser.NamedUser,
  509
+            self._requester,
  510
+            headers,
  511
+            data
  512
+        )
  513
+
500 514
     def get_branches( self ):
501 515
         headers, data = self._requester.requestAndCheck(
502 516
             "GET",
@@ -992,6 +1006,16 @@ def get_watchers( self ):
992 1006
             data
993 1007
         )
994 1008
 
  1009
+    def has_in_assignees( self, assignee ):
  1010
+        assert isinstance( assignee, NamedUser.NamedUser ), assignee
  1011
+        status, headers, data = self._requester.requestRaw(
  1012
+            "GET",
  1013
+            self.url + "/assignees/" + assignee._identity,
  1014
+            None,
  1015
+            None
  1016
+        )
  1017
+        return status == 204
  1018
+
995 1019
     def has_in_collaborators( self, collaborator ):
996 1020
         assert isinstance( collaborator, NamedUser.NamedUser ), collaborator
997 1021
         status, headers, data = self._requester.requestRaw(
45  test/ReplayData/Repository.testAssignees.txt
... ...
@@ -0,0 +1,45 @@
  1
+https GET api.github.com None /users/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  2
+200
  3
+[('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')]
  4
+{"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}
  5
+
  6
+https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
  7
+200
  8
+[('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')]
  9
+{"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"}
  10
+
  11
+https GET api.github.com None /repos/jacquev6/PyGithub/assignees/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null
  12
+204
  13
+[('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')]
  14
+
  15
+
  16
+https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  17
+404
  18
+[('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')]
  19
+{"message":"Not Found"}
  20
+
  21
+https PUT api.github.com None /repos/jacquev6/PyGithub/collaborators/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  22
+204
  23
+[('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')]
  24
+
  25
+
  26
+https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  27
+204
  28
+[('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')]
  29
+
  30
+
  31
+https GET api.github.com None /repos/jacquev6/PyGithub/assignees {'Authorization': 'Basic login_and_password_removed'} null
  32
+200
  33
+[('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')]
  34
+[{"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}]
  35
+
  36
+https DELETE api.github.com None /repos/jacquev6/PyGithub/collaborators/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  37
+204
  38
+[('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')]
  39
+
  40
+
  41
+https GET api.github.com None /repos/jacquev6/PyGithub/assignees/Lyloa {'Authorization': 'Basic login_and_password_removed'} null
  42
+404
  43
+[('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')]
  44
+{"message":"Not Found"}
  45
+
11  test/Repository.py
@@ -339,3 +339,14 @@ def testGetPullsWithArguments( self ):
339 339
 
340 340
     def testLegacySearchIssues( self ):
341 341
         self.assertListKeyEqual( self.repo.legacy_search_issues( "open", "search" ), lambda i: i.title, [ "Support new Search API" ] )
  342
+
  343
+    def testAssignees( self ):
  344
+        lyloa = self.g.get_user( "Lyloa" )
  345
+        jacquev6 = self.g.get_user( "jacquev6" )
  346
+        self.assertTrue( self.repo.has_in_assignees( jacquev6 ) )
  347
+        self.assertFalse( self.repo.has_in_assignees( lyloa ) )
  348
+        self.repo.add_to_collaborators( lyloa )
  349
+        self.assertTrue( self.repo.has_in_assignees( lyloa ) )
  350
+        self.assertListKeyEqual( self.repo.get_assignees(), lambda u: u.login, [ "jacquev6", "Lyloa" ] )
  351
+        self.repo.remove_from_collaborators( lyloa )
  352
+        self.assertFalse( self.repo.has_in_assignees( lyloa ) )

0 notes on commit 696e198

Please sign in to comment.
Something went wrong with that request. Please try again.