예제 #1
0
    def get_purchase_order(self, order_number):
        if not self.logged_in:
            raise Exception("Must be logged in to complete this action")

        order_soup = self.retrieve_purchase_order_soup(order_number)
        order_date = order_soup.find("mark", {"class": "order-date"}).text
        order_date = date_parser.parse(order_date).date()
        order_status = order_soup.find("mark", {"class": "order-status"}).text
        total_cost = order_soup.find("span", {"class": "woocommerce-Price-amount amount"}).text
        total_cost = float(total_cost.replace("$", ""))
        total_items = None
        line_items = self.get_purchase_order_line_items(order_number)
        po = PurchaseOrder(line_items)
        po.status = order_status
        po.date = order_date
        po.total_cost = total_cost
        return po
 def test_add_line_items_from_list_of_line_items(self):
     purchase_order = PurchaseOrder()
     purchase_order.add_line_items(self.line_items)
     self.assertEqual(len(self.line_items), len(purchase_order))
 def test_values(self):
     purchase_order = PurchaseOrder(self.line_items_dict)
     print(purchase_order.values)
 def test_add_line_items_from_list_of_args(self):
     purchase_order = PurchaseOrder()
     purchase_order.add_line_items(self.line_items_list)
     for x in self.line_items_list:
         print(x)
     self.assertEqual(len(self.line_items_list), len(purchase_order))
 def test_add_line_item(self):
     purchase_order = PurchaseOrder()
     purchase_order.add_line_item(self.test_line_item)
     self.assertIn(self.test_line_item, purchase_order.line_items)
 def test_add_line_item_from_dict(self):
     purchase_order = PurchaseOrder()
     purchase_order.add_line_item_from_dict(self.random_line_item_dict)
     self.assertIn(self.random_line_item_dict['id'],
                   purchase_order._line_items.keys())
 def test_add_line_items_from_dict(self):
     purchase_order = PurchaseOrder()
     purchase_order.add_line_items_from_dict(self.line_items_dict)
 def test___init__(self):
     purchase_order = PurchaseOrder(self.line_items_dict)
     self.assertEqual(len(purchase_order), len(self.line_items_dict))