Exemplo n.º 1
0
 def test_update_host_and_url(self):
     url_string = 'http://githubbadge.appspot.com/badge/berkerpeksag?s=1'
     url = Url(url_string)
     old_host = url.host
     self.assertEqual('githubbadge.appspot.com', url.host)
     url.host = 'githubbadge.com'
     self.assertNotEqual(old_host, url.host)
     self.assertEqual(
         'http://githubbadge.com/badge/berkerpeksag?s=1', url.url)
Exemplo n.º 2
0
 def test_update_host_and_url(self):
     url_string = 'http://githubbadge.appspot.com/badge/berkerpeksag?s=1'
     url = Url(url_string)
     old_host = url.host
     self.assertEqual('githubbadge.appspot.com', url.host)
     url.host = 'githubbadge.com'
     self.assertNotEqual(old_host, url.host)
     self.assertEqual('http://githubbadge.com/badge/berkerpeksag?s=1',
                      url.url)
Exemplo n.º 3
0
    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