def test_login_fail(self): """ Tests that a user cannot login when the email is not confirmed, or username/password are wrong """ # missing password assert ( app.post("/session", data=dict(username="******", password=""), follow_redirects=True).status_code == 400 ) # not existing user assert ( app.post("/session", data=dict(username="******", password="******"), follow_redirects=True).status_code == 404 ) create_test_user(app) # wrong password assert ( app.post( "/session", data=dict(username="******", password="******"), follow_redirects=True ).status_code == 404 ) # email is not confirmed assert ( app.post("/session", data=dict(username="******", password="******"), follow_redirects=True).status_code == 403 ) delete_test_user(app)
def test_api_user_post_fails_when_no_args(self): """ Tests that user-post request fails when none of possible args is given """ create_test_user(app) assert app.post("/user/1").status_code == 400 delete_test_user(app)
def test_api_user_post_fails_when_no_args(self): """ Tests that user-post request fails when none of possible args is given """ create_test_user(app) assert app.post('/user/1').status_code == 400 delete_test_user(app)
def test_login_fail(self): """ Tests that a user cannot login when the email is not confirmed, or username/password are wrong """ # missing password assert app.post('/session', data=dict(username='******', password=''), follow_redirects=True).status_code == 400 # not existing user assert app.post('/session', data=dict(username='******', password='******'), follow_redirects=True).status_code == 404 create_test_user(app) # wrong password assert app.post('/session', data=dict(username='******', password='******'), follow_redirects=True).status_code == 404 # email is not confirmed assert app.post('/session', data=dict(username='******', password='******'), follow_redirects=True).status_code == 403 delete_test_user(app)
def test_delete_user(self): # no password assert app.delete("/user/200").status_code == 400 # no password or wrong password create_test_user(app) assert app.delete("/user/1", data=dict(password="")).status_code == 400 assert app.delete("/user/1", data=dict(password="******")).status_code == 400 delete_test_user(app)
def test_api_new_user_confirm_failed_post(self): """ Tests that a new user is created and their email cannot be confirmed with a wrong hash """ create_test_user(app) assert app.post('/user/1', data=dict(confirm='wrong_testing_confirmation_hash'), follow_redirects=True).status_code == 400 delete_test_user(app)
def test_login_logout(self): """ Tests that a user can login and logout successfully """ create_confirmed_test_user(app) assert app.post('/session', data=dict(username='******', password='******'), follow_redirects=True).status_code == 200 assert app.delete('/session', follow_redirects=True).status_code == 204 delete_test_user(app)
def test_api_new_user_confirm_failed_post(self): """ Tests that a new user is created and their email cannot be confirmed with a wrong hash """ create_test_user(app) assert ( app.post("/user/1", data=dict(confirm="wrong_testing_confirmation_hash"), follow_redirects=True).status_code == 400 ) delete_test_user(app)
def test_login_logout(self): """ Tests that a user can login and logout successfully """ create_confirmed_test_user(app) assert ( app.post("/session", data=dict(username="******", password="******"), follow_redirects=True).status_code == 200 ) assert app.delete("/session", follow_redirects=True).status_code == 204 delete_test_user(app)
def test_delete_user(self): # no password assert app.delete('/user/200').status_code == 400 # no password or wrong password create_test_user(app) assert (app.delete('/user/1', data=dict(password='')).status_code == 400) assert (app.delete('/user/1', data=dict(password='******')).status_code == 400) delete_test_user(app)
def test_api_user_update(self): """ Tests that the users' data is updated """ create_test_user(app) assert app.post('/user/1', data=dict(name='Marcus', last_name='Aurelius', profession='Emperor', birthday='0121-04-26')).status_code == 201 # TODO test that the user has really been updated, # when a json-response exists delete_test_user(app)
def test_api_user_update(self): """ Tests that the users' data is updated """ create_test_user(app) assert ( app.post( "/user/1", data=dict(name="Marcus", last_name="Aurelius", profession="Emperor", birthday="0121-04-26") ).status_code == 201 ) # TODO test that the user has really been updated, # when a json-response exists delete_test_user(app)