I'm in the process of writing a test for the login portion of an app I'm creating in Flask. However, when I pass data using the test_client.post()
method my test data isn't being passed correctly.
What's more, the manual login test POSTs and redirects fine.
The test case code is:
# Ensure Login behaves correctly given the correct credentials
def test_correct_login(self):
tester = app.test_client(self)
response = tester.post('/login',data= dict(username = 'bigtest', password = 'testing2'), follow_redirects = True, content_type='application/x-www-form-urlencoded')
self.assertIn(b'Section title', response.data)
The response given shows that the username is passed correct, but the password does not have a value.
This is the response returned in console:
<div class="form-group required">
<label class="control-label" for="username">username</label>
<input class="form-control" id="username" name="username" required type="text" value="bigtest">
</div>
<div class="form-group required">
<label class="control-label" for="password">password</label>
<input class="form-control" id="password" name="password" required type="password" value="">
I'm not sure what the issue is here. Has this happened to anyone else before?