def test_grab_paginated_json(self): # This hits a real URL and incurs a rate limit... # lizardsystem has more than 30 repos, which is the pagination limit. url = commits.ORG_REPOS_URL.format(organization="lizardsystem") result = commits.grab_json(url) print(result) self.assertTrue(len(result) > 30)
def test_grab_json(self): # This hits a real URL, but doesn't incur a rate limit. url = "https://api.github.com/rate_limit" result = commits.grab_json(url) print("In case the tests, fail, perhaps it is because of the github") print("rate limit. Some of the tests really hit the API...") print(result) self.assertTrue("rate" in result)
def test_grab_json_with_json_auth(self): # This hits a real URL, but doesn't incur a rate limit. # The auth is a user/pass list (from json) but the requests lib needs # a tuple. This test checks whether it works properly that way. url = "https://api.github.com/rate_limit" new_settings = copy.deepcopy(commits.SETTINGS) new_settings["auth"] = ["atilla_the_hun", "nonexisting_password"] with mock.patch("githubinfo.commits.SETTINGS", new_settings): result = commits.grab_json(url) self.assertEquals({"message": "Bad credentials"}, result)