def test_update_path_and_url(self): url_string = 'http://githubbadge.appspot.com/badge/berkerpeksag?s=1' url = Url(url_string) old_path = url.path self.assertEqual('/badge/berkerpeksag', url.path) self.assertTrue(url.path.startswith('/')) url.path = 'badge/BYK' self.assertEqual('badge/BYK', url.path) self.assertNotEqual(old_path, url.path) self.assertEqual('http://githubbadge.appspot.com/badge/BYK?s=1', url.url)
def _make_api_call(self, api, resource, parameters, headers): if api not in self.webservice_endpoints: logging.error("Requested API '{}' is not Supported.".format(api)) return false api_url = Url('') api_url.host = self.webservice_hostname api_url.scheme = self.webservice_protocol api_url.path = "{}/{}/{}.{}".format(self.webservice_path, api, resource, self.webservice_format) response = requests.get(api_url.url) if response.status_code != 200: return False if self.webservice_format == 'json': return response.json() return response.text