def test_APIPutWithSimpleQuery(self): wcapi = API(**self.api_params) response = wcapi.get('products') first_product = (response.json())['products'][0] original_title = first_product['title'] product_id = first_product['id'] nonce = str(random.random()) response = wcapi.put('products/%s?filter%%5Blimit%%5D=5' % (product_id), {"product":{"title":str(nonce)}}) request_params = UrlUtils.get_query_dict_singular(response.request.url) response_obj = response.json() self.assertEqual(response_obj['product']['title'], str(nonce)) self.assertEqual(request_params['filter[limit]'], str(5)) wcapi.put('products/%s' % (product_id), {"product":{"title":original_title}})
def test_APIPutWithSimpleQuery(self): wcapi = API(**self.api_params) response = wcapi.get('products') first_product = (response.json())[0] # from pprint import pformat # print "first product %s" % pformat(response.json()) original_title = first_product['name'] product_id = first_product['id'] nonce = str(random.random()) response = wcapi.put('products/%s?page=2&per_page=5' % (product_id), {"name":str(nonce)}) request_params = UrlUtils.get_query_dict_singular(response.request.url) response_obj = response.json() self.assertEqual(response_obj['name'], str(nonce)) self.assertEqual(request_params['per_page'], '5') wcapi.put('products/%s' % (product_id), {"name":original_title})
def test_APIPutWithSimpleQuery(self): wcapi = API(**self.apiParams) nonce = str(random.random()) response = wcapi.put('products/633?filter%5Blimit%5D=5', {"product": { "title": str(nonce) }}) request_params = UrlUtils.get_query_dict_singular(response.request.url) # print "\ntest_APIPutWithSimpleQuery" # print "request url", response.request.url # print "response", UrlUtils.beautify_response(response) response_obj = response.json() # print "response obj", response_obj self.assertEqual(response_obj['product']['title'], str(nonce)) self.assertEqual(request_params['filter[limit]'], str(5))