def test_order(self): with open (os.path.join(os.path.dirname(__file__), "test_data", "shopify_customer.json")) as shopify_customer: shopify_customer = json.load(shopify_customer) create_customer(shopify_customer.get("customer")) with open (os.path.join(os.path.dirname(__file__), "test_data", "shopify_item.json")) as shopify_item: shopify_item = json.load(shopify_item) make_item("_Test Warehouse - _TC", shopify_item.get("product")) with open (os.path.join(os.path.dirname(__file__), "test_data", "shopify_order.json")) as shopify_order: shopify_order = json.load(shopify_order) create_order(shopify_order.get("order"), "_Test Company") sales_order = frappe.get_doc("Sales Order", {"shopify_order_id": cstr(shopify_order.get("order").get("id"))}) self.assertEqual(cstr(shopify_order.get("order").get("id")), sales_order.shopify_order_id) #check for customer shopify_order_customer_id = cstr(shopify_order.get("order").get("customer").get("id")) sales_order_customer_id = frappe.get_value("Customer", sales_order.customer, "shopify_customer_id") self.assertEqual(shopify_order_customer_id, sales_order_customer_id) #check sales invoice sales_invoice = frappe.get_doc("Sales Invoice", {"shopify_order_id": sales_order.shopify_order_id}) self.assertEqual(sales_invoice.rounded_total, sales_order.rounded_total) #check delivery note delivery_note_count = frappe.db.sql("""select count(*) from `tabDelivery Note` where shopify_order_id = %s""", sales_order.shopify_order_id)[0][0] self.assertEqual(delivery_note_count, len(shopify_order.get("order").get("fulfillments")))
def test_order(self): with open( os.path.join(os.path.dirname(__file__), "test_data", "shopify_customer.json")) as shopify_customer: shopify_customer = json.load(shopify_customer) create_customer(shopify_customer.get("customer"), []) with open( os.path.join(os.path.dirname(__file__), "test_data", "shopify_item.json")) as shopify_item: shopify_item = json.load(shopify_item) make_item("_Test Warehouse - _TC", shopify_item.get("product"), []) with open( os.path.join(os.path.dirname(__file__), "test_data", "shopify_order.json")) as shopify_order: shopify_order = json.load(shopify_order) shopify_settings = frappe.get_doc("Shopify Settings", "Shopify Settings") create_order(shopify_order.get("order"), shopify_settings, "_Test Company") sales_order = frappe.get_doc( "Sales Order", {"shopify_order_id": cstr(shopify_order.get("order").get("id"))}) self.assertEqual(cstr(shopify_order.get("order").get("id")), sales_order.shopify_order_id) #check for customer shopify_order_customer_id = cstr( shopify_order.get("order").get("customer").get("id")) sales_order_customer_id = frappe.get_value("Customer", sales_order.customer, "shopify_customer_id") self.assertEqual(shopify_order_customer_id, sales_order_customer_id) #check sales invoice sales_invoice = frappe.get_doc( "Sales Invoice", {"shopify_order_id": sales_order.shopify_order_id}) self.assertEqual(sales_invoice.rounded_total, sales_order.rounded_total) #check delivery note delivery_note_count = frappe.db.sql( """select count(*) from `tabDelivery Note` where shopify_order_id = %s""", sales_order.shopify_order_id)[0][0] self.assertEqual(delivery_note_count, len(shopify_order.get("order").get("fulfillments")))
def test_product(self): with open (os.path.join(os.path.dirname(__file__), "test_data", "shopify_item.json")) as shopify_item: shopify_item = json.load(shopify_item) make_item("_Test Warehouse - _TC", shopify_item.get("product")) item = frappe.get_doc("Item", cstr(shopify_item.get("product").get("id"))) self.assertEqual(cstr(shopify_item.get("product").get("id")), item.shopify_product_id) self.assertEqual(item.sync_with_shopify, 1) #test variant price for variant in shopify_item.get("product").get("variants"): price = frappe.get_value("Item Price", {"price_list": "_Test Price List", "item_code": cstr(variant.get("id"))}, "price_list_rate") self.assertEqual(flt(variant.get("price")), flt(price))
def test_product(self): with open( os.path.join(os.path.dirname(__file__), "test_data", "shopify_item.json")) as shopify_item: shopify_item = json.load(shopify_item) make_item("_Test Warehouse - _TC", shopify_item.get("product"), []) item = frappe.get_doc("Item", cstr(shopify_item.get("product").get("id"))) self.assertEqual(cstr(shopify_item.get("product").get("id")), item.shopify_product_id) self.assertEqual(item.sync_with_shopify, 1) #test variant price for variant in shopify_item.get("product").get("variants"): price = frappe.get_value( "Item Price", { "price_list": "_Test Price List", "item_code": cstr(variant.get("id")) }, "price_list_rate") self.assertEqual(flt(variant.get("price")), flt(price))