Пример #1
0
    def encode_qs_params(self, request):
        # If there is a query string, split it out and include in the
        # parameters. In typical libsaas usage there will never be a query
        # string, since parameters should be passed as Request.params, but just
        # in case someone tried, check it.
        query = port.urlparse(request.uri).query
        params = port.parse_qsl(query, True)

        return tuple((self.encode(key), self.encode(val))
                     for key, val in params)
Пример #2
0
    def encode_qs_params(self, request):
        # If there is a query string, split it out and include in the
        # parameters. In typical libsaas usage there will never be a query
        # string, since parameters should be passed as Request.params, but just
        # in case someone tried, check it.
        query = port.urlparse(request.uri).query
        params = port.parse_qsl(query, True)

        return tuple(
            (self.encode(key), self.encode(val)) for key, val in params)
Пример #3
0
    def test_urlmetrics(self):
        params = {'Cols': '9', 'Signature': '/pZ83jzQ+0589L0giwQkHg5yui0=',
                     'AccessID': 'access-id', 'Expires': '946688761'}

        self.service.urlmetrics('example.org/dir',
                                constants.TITLE + constants.SUBDOMAIN)
        self.expect('GET', '/url-metrics/example.org/dir/', params)

        urls = ['example.org/dir', 'example.net/other']
        self.service.urlmetrics(urls, constants.TITLE + constants.SUBDOMAIN)
        self.assertEqual(self.executor.request.method, 'POST')

        parsed = port.urlparse(self.executor.request.uri)
        self.assertEqual(
            (parsed.scheme, parsed.netloc, parsed.path),
            ('https', 'lsapi.seomoz.com', '/linkscape/url-metrics/'))
        self.assertEqual(dict(port.parse_qsl(parsed.query)), params)
        self.assertEqual(json.loads(self.executor.request.params), urls)