13.7k views
2 votes
Please help me to fix these 2 tests by running each test individually and fixing the error. Many of the error are just the wrong text is being displayed or it is not redirecting the user to the proper web page; however, some errors are more challenging.

1.

def test_index_route(client):

response = client.get("/about")

assert response.status_code == 200

assert b"about me" in response.data

2.

def test_index_route(client):

response = client.get("/")

assert response.status_code == 200

assert b"IS 601" in response.data

User Simplename
by
7.9k points

1 Answer

4 votes

To fix the first test, it seems that the route "/about" is not returning the expected content. You can update the route handler to return the correct response. Here's an example of how you can fix it:

```python

def test_index_route(client):

response = client.get("/about")

assert response.status_code == 200

assert b"about me" in response.data

assert b"This is my about page" in response.data # Update the expected content

```

In this case, you need to update the expected content in the second assert statement to match what should be displayed on the "/about" route.

To fix the second test, it seems that the homepage ("/") is not returning the expected content. You can update the route handler to return the correct response. Here's an example of how you can fix it:

```python

def test_index_route(client):

response = client.get("/")

assert response.status_code == 200

assert b"IS 601 - Home Page" in response.data # Update the expected content

```

In this case, you need to update the expected content in the second assert statement to match what should be displayed on the homepage ("/").

Make sure to update the expected content in both tests according to your application's implementation.

User Austen Chongpison
by
7.4k points