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_customer(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")) customer = frappe.get_doc("Customer", {"shopify_customer_id": cstr(shopify_customer.get("customer").get("id"))}) self.assertEqual(customer.sync_with_shopify, 1) shopify_address = shopify_customer.get("customer").get("addresses")[0] address = frappe.get_doc("Address", {"customer": customer.name}) self.assertEqual(cstr(shopify_address.get("id")), address.shopify_address_id)
def test_customer(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"), []) customer = frappe.get_doc( "Customer", { "shopify_customer_id": cstr(shopify_customer.get("customer").get("id")) }) self.assertEqual(customer.sync_with_shopify, 1) shopify_address = shopify_customer.get("customer").get("addresses")[0] address = frappe.get_doc("Address", {"customer": customer.name}) self.assertEqual(cstr(shopify_address.get("id")), address.shopify_address_id)