ESSA Project - Growing Grubs Web Application. Growing Grubs is a web application designed to help parents find healthy recipes for their children at various stages of development. The application provides a range of features, including recipe search, user profiles, and feeding tips.
def test_favourite_recipe(client, mocker):
# Add a test recipe and user to the database
recipe = Recipe(title='Test Recipe', description='A test recipe for favouriting.')
db.session.add(recipe)
db.session.commit()
# Simulate user login
login_response = login_user(client, 'testuser', 'password1234')
assert login_response.status_code == 200 # Ensure login was successful
# Mock form data to pass recipe title and image
form_data = {
'recipe_title': recipe.title,
'recipe_image': 'test_image.jpg'
}
# Simulate the favourite route
response = client.post(url_for('other_routes.favourite_recipe', recipe_id=recipe.id), data=form_data,
follow_redirects=True)
# Check if the recipe is added to the user's favourites and the response is correct
assert response.status_code == 200
assert b'Recipe added to favourites!' in response.data # Check for success message
E assert b'Recipe added to favourites!' in b'<!DOCTYPE html>\n\n\n
============================================================================================================= FAILURES ============================================================================================================= __ test_favourite_recipe ___
client = <FlaskClient <Flask 'mod'>>, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f6cf31c15d0>