I need to test a function that registers a new user to my database and creates a profile image for that user within the file system.
Normally the function runs when a form is submitted passing the name, phone, password...and image to the function.
This function therefore expects request.files['file'] to hold an image.
How to call the function and predefine the value of request.files['file'] as it were holding a .jpg image?
here is my test case without consideration of the image required!
def registering(self, username, email, password, passwordCheck, phone):
return self.app.post('/registering', data=dict(
username=username,
email=email,
password=password,
passwordCheck=passwordCheck,
phone=phone
), follow_redirects=True)
def test_registering(self):
rv = self.registering('TestUser', 'test@test.com', 'passwordTest', 'passwordTest', '900102030')
assert 'Registered Successfully' in rv.data
Aucun commentaire:
Enregistrer un commentaire