def test_update_order_handler_invalid_item(self): order1 = OrderCreator.get_instance().create_order("small", "none", ["beef"], "coke", "pickup") self.order_handler.data.get_order_manager().add_new_order( order1.get_order_no(), order1 ) delivery1 = DeliveryCreator.get_instance().create_delivery( "1998 Washington Street", order1, order1.get_order_no() ) self.order_handler.data.get_delivery_manager().add_new_delivery( order1.get_delivery(), delivery1, order1.get_delivery_no() ) item = "mood" new_value = "happy" add_topping = False self.assertEqual( self.order_handler.update_order_in_server( order1.get_order_no(), item, new_value, add_topping ), -1 ) self.reset_file()
def test_get_delivery_by_no_valid_input(self): order1 = OrderCreator.get_instance().create_order("small", "none", ["beef"], "coke", "foodora") self.order_handler.data.get_order_manager().add_new_order( order1.get_order_no(), order1 ) delivery1 = DeliveryCreator.get_instance().create_delivery( "1998 Washington Street", order1, order1.get_order_no() ) self.order_handler.data.get_delivery_manager().add_new_delivery( order1.get_delivery(), delivery1, order1.get_delivery_no() ) self.assertEqual( self.order_handler.get_delivery_by_type_no( order1.get_delivery(), order1.get_delivery_no() ).get_delivery_no(), str(order1.get_delivery_no()) ) self.reset_file()
def test_get_order_by_no_valid_input(self): order1 = OrderCreator.get_instance().create_order("small", "none", ["beef"], "coke", "pickup") self.order_handler.data.get_order_manager().add_new_order( order1.get_order_no(), order1 ) self.assertEqual( self.order_handler.get_order_by_no(order1.get_order_no()), order1 ) self.reset_file()
def test_create_order(self): pizza_size = "small" pizza_type = "none" toppings = [] drink = "coke" delivery_type = "pickup" self.assertEqual( OrderCreator.get_instance().create_order( pizza_size, pizza_type, toppings, drink, delivery_type, ), Order(OrderCreator._order_no - 1, pizza_size, pizza_type, toppings, drink, delivery_type, OrderCreator._delivery_no - 1))
def test_create_order(self): pizza_size = "small" pizza_type = "none" toppings = [] drink = "coke" delivery_type = "pickup" address = "17 Wall Street" order = OrderCreator.get_instance().create_order( pizza_size, pizza_type, toppings, drink, delivery_type, ) self.assertEqual( DeliveryCreator.get_instance().create_delivery( address, order, order.get_order_no()), Delivery(OrderCreator._delivery_no - 1, address, order, order.get_order_no()))
def submit_order_to_server(self, pizza_size: str, pizza_type: str, toppings: [str], drink: str, delivery_type: str, address: str) -> int: if not pizza_type.lower() == "none": predefined = self.data.get_pizza_manager().get_predefined() predefined_toppings = [] for d in predefined: if pizza_type in d: predefined_toppings = d[pizza_type] for t in predefined_toppings: if t not in toppings: toppings.append(t) order = OrderCreator.get_instance().create_order( pizza_size, pizza_type, toppings, drink, delivery_type) self.data.get_order_manager().add_new_order(order.get_order_no(), order) delivery = DeliveryCreator.get_instance().create_delivery( address, order, order.get_order_no()) self.data.get_delivery_manager().add_new_delivery( order.get_delivery(), delivery, order.get_delivery_no()) return order.get_order_no()
def test_calculate_total_invalid_order_3(self): order1 = OrderCreator.get_instance().create_order("", "none", ["beef"], "coke", "pickup") self.order_handler.data.get_order_manager().add_new_order( order1.get_order_no(), order1 ) delivery1 = DeliveryCreator.get_instance().create_delivery( "1998 Washington Street", order1, order1.get_order_no() ) self.order_handler.data.get_delivery_manager().add_new_delivery( order1.get_delivery(), delivery1, order1.get_delivery_no() ) self.assertEqual( self.order_handler.calculate_total(order1), 4 ) self.reset_file()
def create_long_client(): return OrderCreator(account.is_test_net(), account.get_api_key_long(), account.get_api_secret_long())
def create_short_client(): return OrderCreator(account.is_test_net(), account.get_api_key_short(), account.get_api_secret_short())