Exemplo n.º 1
0
    def test_edit_meal(self):
        #Creating a new meal
        Caterer().post_meal(1, "Chicken", 200, "dinner", "Monday")

        #Modify meal
        results = Caterer().modify_meal(1, "beef", 200, "dinner", "Tuesday")
        self.assertEqual(results,
                         'Meal modification successful',
                         msg='The meal was modified successfully')
Exemplo n.º 2
0
    def test_post_menu(self):
        #Check empty values are accepted
        results = Caterer().post_menu(4, '', 250, '', "Monday")
        self.assertEqual(results,
                         'Please enter all the details',
                         msg='There is an empty input')

        #Post a menu
        results1 = Caterer().post_menu(5, "Ugali", 300, "lunch", "Monday")
        self.assertEqual(results1, 'Meal successfully added to menu')

        #Check if it's in the menu
        results2 = Caterer().post_menu(5, "Ugali", 300, "lunch", "Monday")
        self.assertEqual(results2, 'Meal exists in menu!')
Exemplo n.º 3
0
    def test_delete_meal(self):
        #Creating a new meal
        Caterer().post_meal(3, "Chicken", 200, "dinner", "Monday")

        #Check if meal doesn't exists
        results = Caterer().delete_ml(2)
        self.assertEqual(results,
                         'Meal unavailable!',
                         msg='The meal does not exist exists')

        #Modify meal
        results = Caterer().delete_ml(3)
        self.assertEqual(results,
                         'Meal Deleted successfully',
                         msg='The meal was deleted successfully')
Exemplo n.º 4
0
def edit_meal(current_user, mealId):
    if not current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    new_meal = Caterer().modify_meal(mealId, request.json['meal_name'],
                                     request.json['price'],
                                     request.json['category'],
                                     request.json['day'])
    return jsonify({"message": new_meal})
Exemplo n.º 5
0
    def test_post_meal(self):
        #Test if any of the entered values are empty
        results = Caterer().post_meal(1, "", 200, "", "Friday")
        self.assertEqual(results,
                         'Please enter all the details',
                         msg='There is an empty input')

        #Creating a new meal
        results1 = Caterer().post_meal(1, "Kukutu", 200, "dinner", "Friday")
        self.assertEqual(results1,
                         'Meal successfully created',
                         msg='Successful addition of meal')

        #Checking if the meal already exists
        results2 = Caterer().post_meal(1, "Kukutu", 200, "dinner", "Friday")
        self.assertEqual(results2,
                         'Meal exists!',
                         msg='The meal already exists')
Exemplo n.º 6
0
def edit_meal(active_user, mealId):
    if not active_user['admin']:
        return 'Only available for Admin!'

    new_meal = Caterer().modify_meal(mealId, request.json['meal_name'],
                                     request.json['price'],
                                     request.json['category'],
                                     request.json['day'])
    return jsonify({"message": new_meal})
Exemplo n.º 7
0
def add_meal(active_user):
    if not active_user['admin']:
        return 'Only available for Admin!'

    new_meal = Caterer().post_meal(request.json['meal_id'],
                                   request.json['meal_name'],
                                   request.json['price'],
                                   request.json['category'],
                                   request.json['day'])
    return jsonify({"message": new_meal})
Exemplo n.º 8
0
def setup_menu(current_user):
    if not current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    post_menu = Caterer().post_menu(request.json['meal_id'],
                                    request.json['meal_name'],
                                    request.json['price'],
                                    request.json['category'],
                                    request.json['day'])
    return jsonify({"messages": post_menu})
Exemplo n.º 9
0
def add_meal(current_user):
    if not current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    new_meal = Caterer().post_meal(request.json['meal_id'],
                                   request.json['meal_name'],
                                   request.json['price'],
                                   request.json['category'],
                                   request.json['day'])
    return jsonify({"message": new_meal})
Exemplo n.º 10
0
    def remove_order(self, meal_id):
        orders = [
            order for order in Caterer().order_list
            if order["meal_id"] == meal_id
        ]
        if not orders:
            return 'Meal doesn\'t exists in orders!'

        Caterer.order_list.remove(orders[0])
        return 'Order removed successfully'
Exemplo n.º 11
0
def setup_menu(active_user):
    if not active_user['admin']:
        return 'Only available for Admin!'

    post_menu = Caterer().post_menu(request.json['meal_id'],
                                    request.json['meal_name'],
                                    request.json['price'],
                                    request.json['category'],
                                    request.json['day'])
    return jsonify({"messages": post_menu})
Exemplo n.º 12
0
    def test_modify_order(self):
        Caterer().post_menu(7, "Ugali", 250, "lunch", "Monday")
        User().make_order(7, "Ugali", 250, "lunch", "Monday", 1, "quantum")

        #Check if meal exists
        results = User().modify_order(3, 3)
        self.assertEqual(results, 'Meal doesn\'t exists in orders!')

        #Modify meal
        results = User().modify_order(7, 3)
        self.assertEqual(results, 'Order  modified Succesfully')
Exemplo n.º 13
0
    def modify_order(self, meal_id, quantity):
        #Should validate the input data types
        orders = [
            order for order in Caterer().order_list
            if order["meal_id"] == meal_id
        ]
        if not orders:
            return 'Meal doesn\'t exists in orders!'

        orde = orders[0]
        price = orde["price"]

        self.output['quantity'] = quantity
        self.output['price'] = price * quantity
        return 'Order  modified Succesfully'
Exemplo n.º 14
0
    def make_order(self, meal_id, meal_name, price, category, day, quantity,
                   username):
        if meal_id == '' or meal_name == '' or price == '' or category == '' or day == '' or quantity == '' or username == '':
            return 'Please enter all the details'

        #Should validate the input data types
        menus = [
            menu for menu in Caterer().menu_list
            if menu["meal_id"] == meal_id and menu['meal_name'] == meal_name
        ]
        if not menus:
            return 'Meal doesn\'t exists in menu!'

        self.output['meal_id'] = meal_id
        self.output['meal_name'] = meal_name
        self.output['price'] = price
        self.output['category'] = category
        self.output['day'] = day
        self.output['quantity'] = quantity
        self.output['username'] = username
        Caterer.order_list.append(self.output)
        return 'Meal successfully added '
Exemplo n.º 15
0
def get_all_meals(current_user):
    if not current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    get_meals = Caterer().get_meals()
    return jsonify({"messages": get_meals})
Exemplo n.º 16
0
    def test_get_menu(self):
        #Post menu
        Caterer().post_menu(6, "Ugali", 300, "lunch", "Monday")

        results = User().get_menu()
        self.assertIsInstance(results, list, msg='Incorrect output type')
Exemplo n.º 17
0
 def test_make_order(self):
     Caterer().post_menu(4, "Ugali", 250, "lunch", "Monday")
     results = User().make_order(4, "Ugali", 250, "lunch", "Monday", 1,
                                 "quantum")
     self.assertEqual(results, 'Meal successfully added ')
Exemplo n.º 18
0
def delete_orders(current_user, orderId):
    if current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    delete = Caterer().remove_order(orderId)
    return jsonify({"messages": 'delete'})
Exemplo n.º 19
0
 def test_get_meal(self):
     Caterer().post_meal(1, "Kuku", 200, "lunch", "Friday")
     results = Caterer().get_meals()
     self.assertIsInstance(results, list, msg='Incorrect output type')
Exemplo n.º 20
0
def delete_meals(current_user, mealId):
    if not current_user['admin']:
        return jsonify({"message": 'Sorry you have no access Priviladges'})

    delete_meal = Caterer().delete_ml(mealId)
    return jsonify({"message": delete_meal})
Exemplo n.º 21
0
 def get_menu(self):
     return Caterer().menu_list
Exemplo n.º 22
0
def get_all_meals(active_user):
    if not active_user['admin']:
        return 'Only available for Admin!'

    get_meals = Caterer().get_meals()
    return jsonify({"messages": get_meals})
Exemplo n.º 23
0
def delete_orders(active_user, orderId):
    if active_user['admin']:
        return 'Only available for users!'

    delete = Caterer().remove_order(orderId)
    return jsonify({"messages": delete})
Exemplo n.º 24
0
 def test_get_orders(self):
     Caterer().post_menu(4, "Ugali", 250, "lunch", "Monday")
     User().make_order(4, "Ugali", 250, "lunch", "Monday", 1, "quantum")
     results = Caterer().get_orders()
     self.assertIsInstance(results, list, msg='Incorrect output type')
Exemplo n.º 25
0
def delete_meals(active_user, mealId):
    if not active_user['admin']:
        return 'Only available for Admin!'

    delete_meal = Caterer().delete_ml(mealId)
    return jsonify({"message": delete_meal})