Skip to content

Commit

Permalink
Add get_organizations() (#748)
Browse files Browse the repository at this point in the history
* Add get_organizations()

* Add unit tests for get_organizations
  • Loading branch information
svend authored and sfdye committed Apr 12, 2018
1 parent 6563ce1 commit 1e0150b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
17 changes: 17 additions & 0 deletions github/MainClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ def get_organization(self, login):
)
return github.Organization.Organization(self.__requester, headers, data, completed=True)

def get_organizations(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /organizations <http://developer.github.com/v3/orgs#list-all-organizations>`_
:param since: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization`
"""
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since
return github.PaginatedList.PaginatedList(
github.NamedUser.NamedUser,
self.__requester,
"/organizations",
url_parameters
)

def get_repo(self, full_name_or_id, lazy=True):
"""
:calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_ or `GET /repositories/:id <http://developer.github.com/v3/repos>`_
Expand Down
6 changes: 6 additions & 0 deletions github/tests/Github_.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def testGetUsers(self):
def testGetUsersSince(self):
self.assertListKeyBegin(self.g.get_users(since=1000), lambda u: u.login, ["sbecker"])

def testGetOrganizations(self):
self.assertListKeyBegin(self.g.get_organizations(), lambda u: u.login, ['errfree', 'engineyard', "ministrycentered", "collectiveidea", "ogc", "sevenwire", "entryway"])

def testGetOrganizationsSince(self):
self.assertListKeyBegin(self.g.get_organizations(since=1000), lambda u: u.login, ["railslove", "railsdog", "netguru", "webhostio", "animikii", "sauspiel", "wherecloud", "triveos"])

def testGetRepos(self):
self.assertListKeyBegin(self.g.get_repos(), lambda r: r.name, ["grit", "merb-core", "rubinius", "god", "jsawesome", "jspec", "exception_logger", "ambition"])

Expand Down
11 changes: 11 additions & 0 deletions github/tests/ReplayData/Github.testGetOrganizations.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
https
GET
api.github.com
None
/organizations
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
None
200
[('content-length', '16820'), ('x-runtime-rack', '0.060304'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-oauth-scopes', ''), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"d0e406262ee703e24070ef22399c6529"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('referrer-policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('status', '200 OK'), ('x-ratelimit-remaining', '4980'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '65E2:468F:1E6478:271827:5ACE9AFB'), ('link', '<https://api.github.com/organizations?since=3043>; rel="next", <https://api.github.com/organizations{?since}>; rel="first"'), ('date', 'Wed, 11 Apr 2018 23:32:12 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1523492466')]
[{"login":"errfree","id":44,"url":"https://api.github.com/orgs/errfree","repos_url":"https://api.github.com/orgs/errfree/repos","events_url":"https://api.github.com/orgs/errfree/events","hooks_url":"https://api.github.com/orgs/errfree/hooks","issues_url":"https://api.github.com/orgs/errfree/issues","members_url":"https://api.github.com/orgs/errfree/members{/member}","public_members_url":"https://api.github.com/orgs/errfree/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/44?v=4","description":null},{"login":"engineyard","id":81,"url":"https://api.github.com/orgs/engineyard","repos_url":"https://api.github.com/orgs/engineyard/repos","events_url":"https://api.github.com/orgs/engineyard/events","hooks_url":"https://api.github.com/orgs/engineyard/hooks","issues_url":"https://api.github.com/orgs/engineyard/issues","members_url":"https://api.github.com/orgs/engineyard/members{/member}","public_members_url":"https://api.github.com/orgs/engineyard/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/81?v=4","description":""},{"login":"ministrycentered","id":119,"url":"https://api.github.com/orgs/ministrycentered","repos_url":"https://api.github.com/orgs/ministrycentered/repos","events_url":"https://api.github.com/orgs/ministrycentered/events","hooks_url":"https://api.github.com/orgs/ministrycentered/hooks","issues_url":"https://api.github.com/orgs/ministrycentered/issues","members_url":"https://api.github.com/orgs/ministrycentered/members{/member}","public_members_url":"https://api.github.com/orgs/ministrycentered/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/119?v=4","description":""},{"login":"collectiveidea","id":128,"url":"https://api.github.com/orgs/collectiveidea","repos_url":"https://api.github.com/orgs/collectiveidea/repos","events_url":"https://api.github.com/orgs/collectiveidea/events","hooks_url":"https://api.github.com/orgs/collectiveidea/hooks","issues_url":"https://api.github.com/orgs/collectiveidea/issues","members_url":"https://api.github.com/orgs/collectiveidea/members{/member}","public_members_url":"https://api.github.com/orgs/collectiveidea/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/128?v=4","description":"We build software to solve real problems."},{"login":"ogc","id":144,"url":"https://api.github.com/orgs/ogc","repos_url":"https://api.github.com/orgs/ogc/repos","events_url":"https://api.github.com/orgs/ogc/events","hooks_url":"https://api.github.com/orgs/ogc/hooks","issues_url":"https://api.github.com/orgs/ogc/issues","members_url":"https://api.github.com/orgs/ogc/members{/member}","public_members_url":"https://api.github.com/orgs/ogc/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/144?v=4","description":null},{"login":"sevenwire","id":150,"url":"https://api.github.com/orgs/sevenwire","repos_url":"https://api.github.com/orgs/sevenwire/repos","events_url":"https://api.github.com/orgs/sevenwire/events","hooks_url":"https://api.github.com/orgs/sevenwire/hooks","issues_url":"https://api.github.com/orgs/sevenwire/issues","members_url":"https://api.github.com/orgs/sevenwire/members{/member}","public_members_url":"https://api.github.com/orgs/sevenwire/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/150?v=4","description":""},{"login":"entryway","id":167,"url":"https://api.github.com/orgs/entryway","repos_url":"https://api.github.com/orgs/entryway/repos","events_url":"https://api.github.com/orgs/entryway/events","hooks_url":"https://api.github.com/orgs/entryway/hooks","issues_url":"https://api.github.com/orgs/entryway/issues","members_url":"https://api.github.com/orgs/entryway/members{/member}","public_members_url":"https://api.github.com/orgs/entryway/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/167?v=4","description":""},{"login":"merb","id":264,"url":"https://api.github.com/orgs/merb","repos_url":"https://api.github.com/orgs/merb/repos","events_url":"https://api.github.com/orgs/merb/events","hooks_url":"https://api.github.com/orgs/merb/hooks","issues_url":"https://api.github.com/orgs/merb/issues","members_url":"https://api.github.com/orgs/merb/members{/member}","public_members_url":"https://api.github.com/orgs/merb/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/264?v=4","description":null},{"login":"moneyspyder","id":359,"url":"https://api.github.com/orgs/moneyspyder","repos_url":"https://api.github.com/orgs/moneyspyder/repos","events_url":"https://api.github.com/orgs/moneyspyder/events","hooks_url":"https://api.github.com/orgs/moneyspyder/hooks","issues_url":"https://api.github.com/orgs/moneyspyder/issues","members_url":"https://api.github.com/orgs/moneyspyder/members{/member}","public_members_url":"https://api.github.com/orgs/moneyspyder/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/359?v=4","description":null},{"login":"sproutit","id":374,"url":"https://api.github.com/orgs/sproutit","repos_url":"https://api.github.com/orgs/sproutit/repos","events_url":"https://api.github.com/orgs/sproutit/events","hooks_url":"https://api.github.com/orgs/sproutit/hooks","issues_url":"https://api.github.com/orgs/sproutit/issues","members_url":"https://api.github.com/orgs/sproutit/members{/member}","public_members_url":"https://api.github.com/orgs/sproutit/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/374?v=4","description":null},{"login":"wrenchlabs","id":489,"url":"https://api.github.com/orgs/wrenchlabs","repos_url":"https://api.github.com/orgs/wrenchlabs/repos","events_url":"https://api.github.com/orgs/wrenchlabs/events","hooks_url":"https://api.github.com/orgs/wrenchlabs/hooks","issues_url":"https://api.github.com/orgs/wrenchlabs/issues","members_url":"https://api.github.com/orgs/wrenchlabs/members{/member}","public_members_url":"https://api.github.com/orgs/wrenchlabs/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/489?v=4","description":null},{"login":"ipvideomarketinfo","id":555,"url":"https://api.github.com/orgs/ipvideomarketinfo","repos_url":"https://api.github.com/orgs/ipvideomarketinfo/repos","events_url":"https://api.github.com/orgs/ipvideomarketinfo/events","hooks_url":"https://api.github.com/orgs/ipvideomarketinfo/hooks","issues_url":"https://api.github.com/orgs/ipvideomarketinfo/issues","members_url":"https://api.github.com/orgs/ipvideomarketinfo/members{/member}","public_members_url":"https://api.github.com/orgs/ipvideomarketinfo/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/555?v=4","description":""},{"login":"revelation","id":728,"url":"https://api.github.com/orgs/revelation","repos_url":"https://api.github.com/orgs/revelation/repos","events_url":"https://api.github.com/orgs/revelation/events","hooks_url":"https://api.github.com/orgs/revelation/hooks","issues_url":"https://api.github.com/orgs/revelation/issues","members_url":"https://api.github.com/orgs/revelation/members{/member}","public_members_url":"https://api.github.com/orgs/revelation/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/728?v=4","description":""},{"login":"railslove","id":1067,"url":"https://api.github.com/orgs/railslove","repos_url":"https://api.github.com/orgs/railslove/repos","events_url":"https://api.github.com/orgs/railslove/events","hooks_url":"https://api.github.com/orgs/railslove/hooks","issues_url":"https://api.github.com/orgs/railslove/issues","members_url":"https://api.github.com/orgs/railslove/members{/member}","public_members_url":"https://api.github.com/orgs/railslove/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/1067?v=4","description":"We're an agile team building new products for the web. And oh boy, we're kind of good at it. Want to work with us?"},{"login":"railsdog","id":1119,"url":"https://api.github.com/orgs/railsdog","repos_url":"https://api.github.com/orgs/railsdog/repos","events_url":"https://api.github.com/orgs/railsdog/events","hooks_url":"https://api.github.com/orgs/railsdog/hooks","issues_url":"https://api.github.com/orgs/railsdog/issues","members_url":"https://api.github.com/orgs/railsdog/members{/member}","public_members_url":"https://api.github.com/orgs/railsdog/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/1119?v=4","description":"Leading Spree Commerce Integration Partner"},{"login":"netguru","id":1146,"url":"https://api.github.com/orgs/netguru","repos_url":"https://api.github.com/orgs/netguru/repos","events_url":"https://api.github.com/orgs/netguru/events","hooks_url":"https://api.github.com/orgs/netguru/hooks","issues_url":"https://api.github.com/orgs/netguru/issues","members_url":"https://api.github.com/orgs/netguru/members{/member}","public_members_url":"https://api.github.com/orgs/netguru/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/1146?v=4","description":"Ruby on Rails and mobile development house"},{"login":"webhostio","id":1147,"url":"https://api.github.com/orgs/webhostio","repos_url":"https://api.github.com/orgs/webhostio/repos","events_url":"https://api.github.com/orgs/webhostio/events","hooks_url":"https://api.github.com/orgs/webhostio/hooks","issues_url":"https://api.github.com/orgs/webhostio/issues","members_url":"https://api.github.com/orgs/webhostio/members{/member}","public_members_url":"https://api.github.com/orgs/webhostio/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/1147?v=4","description":null},{"login":"animikii","id":1190,"url":"https://api.github.com/orgs/animikii","repos_url":"https://api.github.com/orgs/animikii/repos","events_url":"https://api.github.com/orgs/animikii/events","hooks_url":"https://api.github.com/orgs/animikii/hooks","issues_url":"https://api.github.com/orgs/animikii/issues","members_url":"https://api.github.com/orgs/animikii/members{/member}","public_members_url":"https://api.github.com/orgs/animikii/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/1190?v=4","description":""},{"login":"sauspiel","id":1511,"url":"https://api.github.com/orgs/sauspiel","repos_url":"https://api.github.com/orgs/sauspiel/repos","events_url":"https://api.github.com/orgs/sauspiel/events","hooks_url":"https://api.github.com/orgs/sauspiel/hooks","issues_url":"https://api.github.com/orgs/sauspiel/issues","members_url":"https://api.github.com/orgs/sauspiel/members{/member}","public_members_url":"https://api.github.com/orgs/sauspiel/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/1511?v=4","description":""},{"login":"wherecloud","id":1849,"url":"https://api.github.com/orgs/wherecloud","repos_url":"https://api.github.com/orgs/wherecloud/repos","events_url":"https://api.github.com/orgs/wherecloud/events","hooks_url":"https://api.github.com/orgs/wherecloud/hooks","issues_url":"https://api.github.com/orgs/wherecloud/issues","members_url":"https://api.github.com/orgs/wherecloud/members{/member}","public_members_url":"https://api.github.com/orgs/wherecloud/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/1849?v=4","description":""},{"login":"triveos","id":1928,"url":"https://api.github.com/orgs/triveos","repos_url":"https://api.github.com/orgs/triveos/repos","events_url":"https://api.github.com/orgs/triveos/events","hooks_url":"https://api.github.com/orgs/triveos/hooks","issues_url":"https://api.github.com/orgs/triveos/issues","members_url":"https://api.github.com/orgs/triveos/members{/member}","public_members_url":"https://api.github.com/orgs/triveos/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/1928?v=4","description":null},{"login":"lincolnloop","id":1964,"url":"https://api.github.com/orgs/lincolnloop","repos_url":"https://api.github.com/orgs/lincolnloop/repos","events_url":"https://api.github.com/orgs/lincolnloop/events","hooks_url":"https://api.github.com/orgs/lincolnloop/hooks","issues_url":"https://api.github.com/orgs/lincolnloop/issues","members_url":"https://api.github.com/orgs/lincolnloop/members{/member}","public_members_url":"https://api.github.com/orgs/lincolnloop/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/1964?v=4","description":"Makers of high performance web applications."},{"login":"notch8","id":2084,"url":"https://api.github.com/orgs/notch8","repos_url":"https://api.github.com/orgs/notch8/repos","events_url":"https://api.github.com/orgs/notch8/events","hooks_url":"https://api.github.com/orgs/notch8/hooks","issues_url":"https://api.github.com/orgs/notch8/issues","members_url":"https://api.github.com/orgs/notch8/members{/member}","public_members_url":"https://api.github.com/orgs/notch8/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/2084?v=4","description":""},{"login":"edgecase","id":2309,"url":"https://api.github.com/orgs/edgecase","repos_url":"https://api.github.com/orgs/edgecase/repos","events_url":"https://api.github.com/orgs/edgecase/events","hooks_url":"https://api.github.com/orgs/edgecase/hooks","issues_url":"https://api.github.com/orgs/edgecase/issues","members_url":"https://api.github.com/orgs/edgecase/members{/member}","public_members_url":"https://api.github.com/orgs/edgecase/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/2309?v=4","description":""},{"login":"galaxycats","id":2548,"url":"https://api.github.com/orgs/galaxycats","repos_url":"https://api.github.com/orgs/galaxycats/repos","events_url":"https://api.github.com/orgs/galaxycats/events","hooks_url":"https://api.github.com/orgs/galaxycats/hooks","issues_url":"https://api.github.com/orgs/galaxycats/issues","members_url":"https://api.github.com/orgs/galaxycats/members{/member}","public_members_url":"https://api.github.com/orgs/galaxycats/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/2548?v=4","description":""},{"login":"standout","id":2595,"url":"https://api.github.com/orgs/standout","repos_url":"https://api.github.com/orgs/standout/repos","events_url":"https://api.github.com/orgs/standout/events","hooks_url":"https://api.github.com/orgs/standout/hooks","issues_url":"https://api.github.com/orgs/standout/issues","members_url":"https://api.github.com/orgs/standout/members{/member}","public_members_url":"https://api.github.com/orgs/standout/public_members{/member}","avatar_url":"https://avatars3.githubusercontent.com/u/2595?v=4","description":null},{"login":"trabian","id":2705,"url":"https://api.github.com/orgs/trabian","repos_url":"https://api.github.com/orgs/trabian/repos","events_url":"https://api.github.com/orgs/trabian/events","hooks_url":"https://api.github.com/orgs/trabian/hooks","issues_url":"https://api.github.com/orgs/trabian/issues","members_url":"https://api.github.com/orgs/trabian/members{/member}","public_members_url":"https://api.github.com/orgs/trabian/public_members{/member}","avatar_url":"https://avatars2.githubusercontent.com/u/2705?v=4","description":""},{"login":"wesabe","id":2842,"url":"https://api.github.com/orgs/wesabe","repos_url":"https://api.github.com/orgs/wesabe/repos","events_url":"https://api.github.com/orgs/wesabe/events","hooks_url":"https://api.github.com/orgs/wesabe/hooks","issues_url":"https://api.github.com/orgs/wesabe/issues","members_url":"https://api.github.com/orgs/wesabe/members{/member}","public_members_url":"https://api.github.com/orgs/wesabe/public_members{/member}","avatar_url":"https://avatars1.githubusercontent.com/u/2842?v=4","description":null},{"login":"orgsync","id":2925,"url":"https://api.github.com/orgs/orgsync","repos_url":"https://api.github.com/orgs/orgsync/repos","events_url":"https://api.github.com/orgs/orgsync/events","hooks_url":"https://api.github.com/orgs/orgsync/hooks","issues_url":"https://api.github.com/orgs/orgsync/issues","members_url":"https://api.github.com/orgs/orgsync/members{/member}","public_members_url":"https://api.github.com/orgs/orgsync/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/2925?v=4","description":""},{"login":"UntoThisLast","id":3043,"url":"https://api.github.com/orgs/UntoThisLast","repos_url":"https://api.github.com/orgs/UntoThisLast/repos","events_url":"https://api.github.com/orgs/UntoThisLast/events","hooks_url":"https://api.github.com/orgs/UntoThisLast/hooks","issues_url":"https://api.github.com/orgs/UntoThisLast/issues","members_url":"https://api.github.com/orgs/UntoThisLast/members{/member}","public_members_url":"https://api.github.com/orgs/UntoThisLast/public_members{/member}","avatar_url":"https://avatars0.githubusercontent.com/u/3043?v=4","description":null}]

0 comments on commit 1e0150b

Please sign in to comment.