def test_list_force_show_deleted(self): """Test list method by add force show deleted option.""" kwargs = {'force_show_deleted': True} list(self.mgr.list(kwargs)) expect = [('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None)] self.assertEqual(expect, self.api.calls)
def test_list_no_data(self): """Test list method by add marker option.""" kwargs = {'marker': 'nodata'} list(self.mgr.list(kwargs)) expect = [('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None)] self.assertEqual(expect, self.api.calls)
def test_list_limit(self): """Test list method by add limit option.""" kwargs = {'limit': 1} list(self.mgr.list(kwargs)) expect = [('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None)] self.assertEqual(expect, self.api.calls)
def test_list_limit(self): """Test list method by add limit option.""" kwargs = {'limit': 1} list(self.mgr.list(kwargs)) expect = [ ('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None) ] self.assertEqual(expect, self.api.calls)
def test_list_force_show_deleted(self): """Test list method by add force show deleted option.""" kwargs = {'force_show_deleted': True} list(self.mgr.list(kwargs)) expect = [ ('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None) ] self.assertEqual(expect, self.api.calls)
def test_list_no_data(self): """Test list method by add marker option.""" kwargs = {'marker': 'nodata'} list(self.mgr.list(kwargs)) expect = [ ('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None) ] self.assertEqual(expect, self.api.calls)
def test_list_ticket_type_encoding(self): """Test 'List search of tickettemplate.' Test of if you filtering multi byte ticket type. """ kwargs = {'ticket_type': u"ni\xf1o"} tickettemplate = list(self.mgr.list(kwargs)) expect = [('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None)] self.assertEqual(expect, self.api.calls) self.assertEqual(1, len(tickettemplate))
def test_list_multi_ticket_type(self): """Test 'List search of tickettemplate.' Test of if you filtering multiple ticket type. """ kwargs = {'ticket_type': 'New Contract,request'} tickettemplate = list(self.mgr.list(kwargs)) expect = [('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None)] self.assertEqual(expect, self.api.calls) self.assertEqual(2, len(tickettemplate))
def test_list_multi_ticket_type(self): """Test 'List search of tickettemplate.' Test of if you filtering multiple ticket type. """ kwargs = {'ticket_type': 'New Contract,request'} tickettemplate = list(self.mgr.list(kwargs)) expect = [ ('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None) ] self.assertEqual(expect, self.api.calls) self.assertEqual(2, len(tickettemplate))
def test_list_ticket_type_encoding(self): """Test 'List search of tickettemplate.' Test of if you filtering multi byte ticket type. """ kwargs = {'ticket_type': u"ni\xf1o"} tickettemplate = list(self.mgr.list(kwargs)) expect = [ ('GET', '/v1/tickettemplates?' + common_utils.urlencode(kwargs), {}, None) ] self.assertEqual(expect, self.api.calls) self.assertEqual(1, len(tickettemplate))
def list(self, kwargs=None): """Get a list of ticket. :param kwargs: Filterling row data<key=value>. """ url = "/v1/tickets" eixsts_ticket_type = False if kwargs: url = url + "?" # If user set catalog filter, it change to list parameter. # This process is necessary for 'AND' search condition. if kwargs and 'ticket_type' in kwargs: eixsts_ticket_type = True ticket_type = kwargs.pop('ticket_type', []) ticket_type_url = '' if not isinstance(ticket_type, list): ticket_type = [ticket_type] for i in range(0, len(ticket_type)): value = ticket_type[i] if i != 0: ticket_type_url = ticket_type_url + '&' ticket_type_url = ticket_type_url + \ parse.urlencode({'ticket_type': value}) url = url + ticket_type_url if kwargs: url = url + ('&' if eixsts_ticket_type else '') \ + utils.urlencode(kwargs) response_key = "tickets" resp, body = self.client.get(url) data = [] for row in body[response_key]: ticket = Ticket(self, row, loaded=True) data.append(ticket) return data
def list(self, kwargs=None): """Get contract list. :param kwargs: Request parameters. """ url = "/v1/contract" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "contract" resp, body = self.client.get(url) data = [] for row in body[response_key]: contract = Contract(self, row, loaded=True) data.append(contract) return data
def list(self, catalog_id, kwargs=None): """Get catalog_contents list. :param kwargs: Request parameters. """ url = "/v1/catalog/%s/contents" % catalog_id if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_contents" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_contents = CatalogContents(self, row, loaded=True) data.append(catalog_contents) return data
def list(self, catalog_id, kwargs=None): """Get catalog_contents list. :param kwargs: Request parameters. """ url = "/v1/catalog/%s/contents" % catalog_id if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_contents" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_contents = CatalogContents(self, row, loaded=True) data.append(catalog_contents) return data
def list(self, kwargs=None): """Get a list of catalog scope. :param kwargs: Filtering row data<key=value>. """ url = "/v1/catalogs/scope" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_scope" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_scope = CatalogScope(self, row, loaded=True) data.append(catalog_scope) return data
def list(self, kwargs=None): """Get a list of catalog scope. :param kwargs: Filtering row data<key=value>. """ url = "/v1/catalogs/scope" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_scope" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_scope = CatalogScope(self, row, loaded=True) data.append(catalog_scope) return data
def list(self, kwargs=None): """Get a list of valid catalog. :param kwargs: Filtering row data<key=value>. """ url = "/v1/catalogs" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "valid_catalog" resp, body = self.client.get(url) data = [] for row in body[response_key]: valid_list = ValidCatalog(self, row, loaded=True) data.append(valid_list) return data
def list(self, kwargs=None): """Get a list of valid catalog. :param kwargs: Filtering row data<key=value>. """ url = "/v1/catalogs" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "valid_catalog" resp, body = self.client.get(url) data = [] for row in body[response_key]: valid_list = ValidCatalog(self, row, loaded=True) data.append(valid_list) return data
def list(self, kwargs=None): """Get a list of goods. :param kwargs: Filterling row data<key=value>. """ url = "/v1/goods" if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "goods" resp, body = self.client.get(url) data = [] for row in body[response_key]: goods = Goods(self, row, loaded=True) data.append(goods) return data
def list(self, catalog_id, kwargs=None): """Get a list of catalog_price. :param catalog_id: Filterling catalog id. :param kwargs: Filterling row data<key=value>. """ url = "/v1/catalog/%s/price" % catalog_id if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_price" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_price = Price(self, row, loaded=True) data.append(catalog_price) return data
def list(self, catalog_id, kwargs=None): """Get a list of catalog_price. :param catalog_id: Filterling catalog id. :param kwargs: Filterling row data<key=value>. """ url = "/v1/catalog/%s/price" % catalog_id if kwargs: url = url + "?" + utils.urlencode(kwargs) response_key = "catalog_price" resp, body = self.client.get(url) data = [] for row in body[response_key]: catalog_price = Price(self, row, loaded=True) data.append(catalog_price) return data
def list(self, kwargs=None): """Get a list of ticket tempates. :param kwargs: Filterling row data<key=value>. """ url = "/v1/tickettemplates" if kwargs: url = url + "?" sort_key = kwargs.pop('sort_key', []) \ if kwargs and 'sort_key' in kwargs \ else [] sort_dir = kwargs.pop('sort_dir', []) \ if kwargs and 'sort_dir' in kwargs \ else [] if len(sort_key) != len(sort_dir): raise exc.HTTPBadRequest( "Unexpected number of sort directions: " "either provide a single sort direction or an equal " "number of sort keys and sort directions.") for key in sort_key: url = '%s&sort_key=%s' % (url, key) for dir in sort_dir: url = '%s&sort_dir=%s' % (url, dir) if kwargs: url = url + "&" + utils.urlencode(kwargs) response_key = "tickettemplates" resp, body = self.client.get(url) data = body[response_key] return [ self.resource_class(self, row, loaded=True) for row in data if row ]
def list(self, kwargs=None): """Get a list of ticket tempates. :param kwargs: Filterling row data<key=value>. """ url = "/v1/tickettemplates" if kwargs: url = url + "?" sort_key = kwargs.pop('sort_key', []) \ if kwargs and 'sort_key' in kwargs \ else [] sort_dir = kwargs.pop('sort_dir', []) \ if kwargs and 'sort_dir' in kwargs \ else [] if len(sort_key) != len(sort_dir): raise exc.HTTPBadRequest( "Unexpected number of sort directions: " "either provide a single sort direction or an equal " "number of sort keys and sort directions.") for key in sort_key: url = '%s&sort_key=%s' % (url, key) for dir in sort_dir: url = '%s&sort_dir=%s' % (url, dir) if kwargs: url = url + "&" + utils.urlencode(kwargs) response_key = "tickettemplates" resp, body = self.client.get(url) data = body[response_key] return [self.resource_class(self, row, loaded=True) for row in data if row]
def test_urlencode(self): self.assertEqual('1=1', utils.urlencode({1: 1})) self.assertEqual('1=1', utils.urlencode({"1": "1"})) self.assertEqual('1=%2F1', utils.urlencode({"1": u"/1"}))
def test_urlencode(self): self.assertEqual('1=1', utils.urlencode({1: 1})) self.assertEqual('1=1', utils.urlencode({"1": "1"})) self.assertEqual('1=%2F1', utils.urlencode({"1": u"/1"}))