def convertResponseToJson(response): jsn = None try: jsn = json2.loads(response.read()) except Exception as exept: print(exept) return jsn
def test_index(self, app, client): with app.app_context(): InitializeProduct() response = client.get("/") assert response.status_code == 200 jsonResponse = json2.loads(response.get_data()) assert jsonResponse["products"] is not None assert len(jsonResponse["products"]) == 50
def test_create_new_order(self, app, client): with app.app_context(): InitializeProduct() response = client.post("/order", json={"product": [{"quantity": 1, "id": 1},{"quantity": 1, "id": 2}]}) assert response.status_code == 302 assert response.location == "http://localhost/order/1" response = client.get("/order/1") assert response.status_code == 200 jsonResponse = json2.loads(response.get_data()) assert jsonResponse['product']['product_quantity'] == 1 assert jsonResponse['product']['product_id'] == 1 response = client.put("/order/1", json={"order": {"email": "*****@*****.**", "shipping_information": {"country": "Canada", "address": "201, rue des rosiers", "postal_code": "G7X 3Y9", "city": "Chicoutimi", "province": "QC"}}}) assert response.status_code == 200 jsonResponse = json2.loads(response.get_data()) assert jsonResponse['email'] == "*****@*****.**" assert jsonResponse['shipping_information']['country'] == "Canada" assert jsonResponse['shipping_information']['address'] == "201, rue des rosiers" assert jsonResponse['shipping_information']['postal_code'] == "G7X 3Y9" assert jsonResponse['shipping_information']['city'] == "Chicoutimi" assert jsonResponse['shipping_information']['province'] == "QC" response = client.put("/order/1", json={ "credit_card": {"name": "John Doe", "number": "4242 4242 4242 4242", "expiration_year": 2024, "cvv": "123", "expiration_month": 9}}) assert response.status_code == 200 jsonResponse = json2.loads(response.get_data()) assert jsonResponse['credit_card']['name'] == 'John Doe' assert jsonResponse['credit_card']['number'] == "4242 4242 4242 4242" assert jsonResponse['credit_card']['expiration_year'] == 2024 assert jsonResponse['credit_card']['expiration_month'] == 9 assert jsonResponse['paid'] is True assert jsonResponse['transaction']['id'] is not None assert jsonResponse['transaction']['success'] is True assert jsonResponse['transaction']['amount_charged'] is not None
'image': 'https://cdn.shopify.com/s/files/1/2017/8131/products/TouchyFeelyVelourDress_04_1024x.jpg?v=1574073885', # 'image': 'http://127.0.0.1:4555/image', # 'gender': '{string}', # 'limit': '1', }) conn = http.client.HTTPSConnection('api.mirrorthatlook.com') conn.request("GET", "/v2/mirrorthatlook?%s" % params, "{body}", headers) response = conn.getresponse() data = response.read() # print(data) my_json = data.decode('utf8') python_obj = json2.loads(my_json) loaded_json = json2.dumps(my_json) loaded_json = json2.loads(my_json) #this works to classify the group that the item is in from the image print((loaded_json["result"])) #print((loaded_json["result"][0]["group"])) print(loaded_json) print((loaded_json["result"][0]["products"][0]["affiliates"][0]["link"])) for x in range(21): print((loaded_json["result"][0]["products"][x]["affiliates"][0]["link"])) #new_json = str(new_json).strip('[]') #print(python_obj.items())