def test_limit_url(self):
        url = "test-url"
        self.assertEqual(url, common.limit_url(url, limit=None, marker=None))

        limit = "test-limit"
        marker = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected,
                         common.limit_url(url, limit=limit, marker=marker))
    def test_limit_url(self):
        url = "test-url"
        self.assertEqual(url, common.limit_url(url, limit=None, marker=None))

        limit = "test-limit"
        marker = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected,
                         common.limit_url(url, limit=limit, marker=marker))
    def test_limit_url(self):
        url_ = "test-url"
        limit_ = None
        marker_ = None
        self.assertEqual(url_, common.limit_url(url_))

        limit_ = "test-limit"
        marker_ = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected, common.limit_url(url_, limit=limit_, marker=marker_))
Exemple #4
0
    def test_limit_url(self):
        url_ = "test-url"
        limit_ = None
        marker_ = None
        self.assertEqual(url_, common.limit_url(url_))

        limit_ = "test-limit"
        marker_ = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected,
                         common.limit_url(url_, limit=limit_, marker=marker_))
Exemple #5
0
 def _paginated(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(common.limit_url(url, limit, marker))
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = parse.urlparse(link)
         query_dict = dict(parse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker')
     data = [self.resource_class(self, res) for res in body[response_key]]
     return common.Paginated(data, next_marker=next_marker, links=links)
Exemple #6
0
 def _paginated(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(common.limit_url(url, limit, marker))
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = parse.urlparse(link)
         query_dict = dict(parse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker')
     data = [self.resource_class(self, res) for res in body[response_key]]
     return common.Paginated(data, next_marker=next_marker, links=links)
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get("links", [])
     next_links = [link["href"] for link in links if link["rel"] == "next"]
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlparse.urlparse(link)
         query_dict = dict(urlparse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get("marker", None)
     instances = body[response_key]
     instances = [self.resource_class(self, res) for res in instances]
     return Paginated(instances, next_marker=next_marker, links=links)
Exemple #8
0
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     check_for_exceptions(resp, body)
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlutils.urlparse(link)
         query_dict = dict(urlutils.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker', None)
     users = [self.resource_class(self, res) for res in body[response_key]]
     return Paginated(users, next_marker=next_marker, links=links)
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     check_for_exceptions(resp, body)
     if not body:
         raise Exception("Call to " + url +
                         " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlutils.urlparse(link)
         query_dict = dict(urlutils.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker', None)
     users = [self.resource_class(self, res) for res in body[response_key]]
     return Paginated(users, next_marker=next_marker, links=links)