Complete the code to send a POST request with form data using Flask's test client.
with app.test_client() as client: response = client.post('/submit', data=[1]) assert response.status_code == 200
The data parameter expects a dictionary representing form fields and values.
Complete the code to check the response contains the submitted form value.
with app.test_client() as client: response = client.post('/submit', data={'username': 'bob'}) assert [1] in response.get_data(as_text=True)
We check if the submitted value 'bob' appears in the response text.
Fix the error in the test code to correctly simulate a form POST with Flask test client.
response = client.post('/login', [1]='user=admin&pass=1234')
Form data must be sent using the data parameter, not json or others.
Fill both blanks to send form data and check the response status code.
with app.test_client() as client: response = client.post('/register', data=[1]) assert response.status_code == [2]
We send form data as a dictionary and expect HTTP status code 200 for success.
Fill all three blanks to test a form POST and verify the response contains the submitted username.
with app.test_client() as client: response = client.post('/profile', data=[1]) content = response.get_data(as_text=True) assert [2] in content assert response.status_code == [3]
We send the username in form data, check that username appears in response text, and expect status 200.