Veebaa / Growing-Grubs

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.
0 stars 0 forks source link

FAILED tests/test_routes.py::test_favourite_recipe #17

Open Veebaa opened 1 week ago

Veebaa commented 1 week ago

============================================================================================================= FAILURES ============================================================================================================= __ test_favourite_recipe ___

client = <FlaskClient <Flask 'mod'>>, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f6cf31c15d0>

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\n \n \n Profile Page\n \n \n \n \n \n \n \n \n \n\n\n\n \n

\n header-image\n
\n\n ...ton" onclick="closeConfirmation()">Cancel\n \n
\n\n \n \n \n\n\n \n\n\n' E + where b'<!DOCTYPE html>\n\n\n\n \n \n Profile Page\n \n \n \n \n \n \n \n \n \n\n\n\n \n
\n header-image\n
\n\n ...ton" onclick="closeConfirmation()">Cancel\n \n
\n\n \n \n \n\n\n \n\n\n' = <WrapperTestResponse 10289 bytes [200 OK]>.data

tests/test_routes.py:257: AssertionError