def _list_base(self, detailed=True, marker=None, limit=None): path = '/os-hypervisors' if detailed: path += '/detail' params = {} if limit is not None: params['limit'] = int(limit) if marker is not None: params['marker'] = str(marker) path += utils.prepare_query_string(params) return self._list(path, 'hypervisors')
def test_convert_dict_to_string(self): ustr = b'?\xd0\xbf=1&\xd1\x80=2' if six.PY3: # in py3 real unicode symbols will be urlencoded ustr = ustr.decode('utf8') cases = ( ({}, ''), ({'2': 2, '10': 1}, '?10=1&2=2'), ({'abc': 1, 'abc1': 2}, '?abc=1&abc1=2'), ({b'\xd0\xbf': 1, b'\xd1\x80': 2}, ustr), ({(1, 2): '1', (3, 4): '2'}, '?(1, 2)=1&(3, 4)=2') ) for case in cases: self.assertEqual( case[1], parse.unquote_plus(utils.prepare_query_string(case[0])))
def list(self, user_id=None, marker=None, limit=None): """ Get a list of keypairs. :param user_id: Id of key-pairs owner (Admin only). :param marker: Begin returning keypairs that appear later in the keypair list than that represented by this keypair name (optional). :param limit: maximum number of keypairs to return (optional). """ params = {} if user_id: params['user_id'] = user_id if limit: params['limit'] = int(limit) if marker: params['marker'] = str(marker) query_string = utils.prepare_query_string(params) url = '/%s%s' % (self.keypair_prefix, query_string) return self._list(url, 'keypairs')
def test_convert_dict_to_string(self): for case in self.cases: self.assertEqual( case[1], parse.unquote_plus(utils.prepare_query_string(case[0])))