I would like to fake request parameters for unit testing. How can I achieve this in Flask?
here is a complete code example of a unit test
testapp = app.test_client()
class Test_test(unittest.TestCase):
def test_user_registration_bad_password_short(self):
response = self.register(name='pat',
email='me@mail.com',
password='Flask',
password2='Flask')
self.assertEqual(response.status_code, 200)
self.assertIn(b'password should be 8 or more characters long',
response.data)
def register(self, name, email, password, password2):
return testapp.post(
'/register',
data=dict(username=name,
email=email,
password=password,
password2=password2),
follow_redirects=True
)