def test_update_meal_when_meal_is_deleted(
        self,
        mock_get,
        mock_request_params
    ):
        '''Test update_meal when the meal is deleted.
        '''
        # Arrange
        with self.app.app_context():
            mock_get.return_value = self.mock_deleted_meal_item
            mock_request_params.return_value = ('Mock', 'Mock', 'Mock')
            meal_item_controller = MealItemController(self.request_context)

            # Act
            result = meal_item_controller.update_meal(1)

            # Assert
            assert result.status_code == 400
            assert result.get_json()['msg'] == 'Bad Request. This meal item ' \
                'is deleted'
    def test_update_meal_when_meal_doesnot_exist(
        self,
        mock_get,
        mock_request_params
    ):
        '''Test update_meal when the meal doesnot exist.
        '''
        # Arrange
        with self.app.app_context():
            mock_request_params.return_value = ('Mock', 'Mock', 'Mock')
            mock_get.return_value = None
            meal_item_controller = MealItemController(self.request_context)

            # Act
            result = meal_item_controller.update_meal(1)

            # Assert
            assert result.status_code == 400
            assert result.get_json()['msg'] == 'Invalid or incorrect meal_id' \
                ' provided'
    def test_update_meal_ok_response(
        self,
        mock_get_unpaginated,
        mock_get,
        mock_request_params
    ):
        '''Test update_meal OK response.
        '''
        # Arrange
        with self.app.app_context():
            mock_get.return_value = MealItemFactory(id=1)
            mock_request_params.return_value = ('mock', 'mock', 'mock')
            mock_get_unpaginated.return_value = None
            meal_item_controller = MealItemController(self.request_context)

            # Act
            result = meal_item_controller.update_meal(1)
            
            # Assert
            assert result.status_code == 200
            assert result.get_json()['msg'] == 'OK'
    def test_update_meal_when_name_already_exists(
        self,
        mock_get_unpaginated,
        mock_get,
        mock_request_params
    ):
        '''Test update_meal when meal name already exists.
        '''
        # Arrange
        with self.app.app_context():
            mock_request_params.return_value = ('mock', 'mock', 'mock')
            mock_get.return_value = self.mock_meal_item
            mock_get_unpaginated.return_value = self.mock_meal_item
            meal_item_controller = MealItemController(self.request_context)

            # Act
            result = meal_item_controller.update_meal(1)

            # Assert
            assert result.status_code == 400
            assert result.get_json()['msg'] == 'Meal item with this name ' \
                'already exists'