def test_loginfresh_unconfirmed_user(self, api, client): user = User("unconfirmedUser", "*****@*****.**", "unconfirmed123") user.save() url = api.url_for(LoginFresh) response = client.post(url, data={"email": "*****@*****.**", "password": "******" }) response_json = get_response_json(response.data) assert(response.status_code == 401) assert(response_json["errors"]["login"] is not None)
def test_confirmation_valid_user_no_confirmation_registered( self, api, client): user = User("noConfUser", "*****@*****.**", "password123") user.save() url = api.url_for(Confirmation) response = client.post(url, data={ "username": "******", "confirmationCode": "correctConfirmationCode" }) response_json = get_response_json(response.data) assert (response.status_code == 422) assert (response_json["errors"]["confirmation"] is not None)
def test_confirmation_code_expired(self, api, client): user = User("expiredUser", "*****@*****.**", "password123") user.save() userConf = UserConfirmation("expiredUser", "expiredCode") userConf.created_at = dt.datetime.utcnow() - dt.timedelta(hours=2) userConf.save() url = api.url_for(Confirmation) response = client.post(url, data={ "username": "******", "confirmationCode": "expiredCode" }) response_json = get_response_json(response.data) assert (response.status_code == 422) assert (response_json["errors"]["confirmation"] is not None)
def test_username_unique(self, db): user1 = User('new', '*****@*****.**') user1.save() try: user2 = User('new', '*****@*****.**') user2.save() # should fail except: db.session.rollback() num_users = db.session.query(User).count() assert (num_users == 1)
def test_get_by_id(self): new_user = User('foo', '*****@*****.**') new_user.save() retrieved_user = User.get_by_id(new_user.id) assert (retrieved_user == new_user)
def test_confirmed_defaults_to_false(self): user = User('user', '*****@*****.**') user.save() assert (user.confirmed is False)
def setup(self): user = User("confUser", "*****@*****.**", "password123") user.save() userConf = UserConfirmation("confUser", "correctConfirmationCode") userConf.save()