Commits

Ian Cordasco  committed 90ce44a

Add iter_all_{repos,users}

Reference: 996f8fdd2da0fa9f669d26700c5a9ec7cf2cd271

  • Participants
  • Parent commits fe66189

Comments (0)

Files changed (4)

File docs/api.rst

 
 ------
 
+.. autofunction:: github3.iter_all_repos
+
+------
+
+.. autofunction:: github3.iter_all_users
+
+------
+
 .. autofunction:: github3.iter_events
 
 ------

File github3/api.py

     return gh.gitignore_templates()
 
 
+def iter_all_repos(number=-1):
+    """Iterate over every repository in the order they were created.
+
+    :param int number: (optional), number of repositories to return.
+        Default: -1, returns all of them
+    :returns: generator of :class:`Repository <github3.repos.Repository>`
+    """
+    return gh.iter_all_repos(number)
+
+
+def iter_all_users(number=-1):
+    """Iterate over every user in the order they signed up for GitHub.
+
+    :param int number: (optional), number of users to return. Default: -1,
+        returns all of them
+    :returns: generator of :class:`User <github3.users.User>`
+    """
+    return gh.iter_all_users(number)
+
+
 def iter_events(number=-1):
     """Iterate over public events.
 

File github3/github.py

             return repo.issue(number)
         return None
 
+    def iter_all_repos(self, number=-1):
+        """Iterate over every repository in the order they were created.
+
+        :param int number: (optional), number of repositories to return.
+            Default: -1, returns all of them
+        :returns: generator of :class:`Repository <github3.repos.Repository>`
+        """
+        url = self._build_url('repositories')
+        return self._iter(int(number), url, Repository)
+
+    def iter_all_users(self, number=-1):
+        """Iterate over every user in the order they signed up for GitHub.
+
+        :param int number: (optional), number of users to return. Default: -1,
+            returns all of them
+        :returns: generator of :class:`User <github3.users.User>`
+        """
+        url = self._build_url('users')
+        return self._iter(int(number), url, User)
+
     @requires_basic_auth
     def iter_authorizations(self, number=-1):
         """Iterate over authorizations for the authenticated user. This will

File tests/test_repos.py

         expect(self.repo.create_blob(None, None)) == ''
         expect(self.repo.create_blob(content, encoding)) == sha
         self.mock_assertions()
+
+    def test_create_comment(self):
+        self.request.return_value = generate_response('commit_comment', 201)
+        body = ('Late night commits are never a good idea. I refactored a '
+                'bit. `User` objects and `Organization` objects share a lot '
+                'of common attributes. I turned those common attributes into '
+                'one `BaseAccount` class to make things simpler. ')
+        sha = 'd41566090114a752eb3a87dbcf2473eb427ef0f3'
+        self.args = ('post', self.api + 'commits/{0}/comments'.format(sha))
+        self.conf = {
+            'data': {
+                'body': body, 'commit_id': sha, 'line': 1, 'path': '',
+                'position': 1
+            }
+        }
+
+        with expect.githuberror():
+            self.repo.create_comment(body, sha)
+
+        self.login()
+        expect(self.repo.create_comment(None, None)).is_None()
+        expect(self.repo.create_comment(body, sha, line=0)).is_None()
+        expect(self.repo.create_comment(body, sha)
+               ).isinstance(github3.repos.RepoComment)
+        self.mock_assertions()