def test_get_user_all(self, session): """Test method get_user_all in User""" users = User.get_user_all() assert len(users) == len(self.userList) assert users[0].id == self.userList[0].id assert users[0].name == self.userList[0].name assert users[0].email == self.userList[0].email assert users[0].password == self.userList[0].password user = User("DUMMY", "*****@*****.**", "hackPr00f", None, None, True) user.user_type_id = UserType.get_type_by_name('USER').id user.activated = True session.add(user) session.commit() self.userList.append(user) users = User.get_user_all() assert len(users) == len(self.userList) session.query(User).delete() session.commit() users = User.get_user_all(False) assert users == [] #Test something that really shouldn't be there with pytest.raises(DbException) as err: User.get_user_all() assert str(err.value) == "(404, 'No user found.')"
def get_user_all_action(): """ Get all user, only for logged users Token is taken from url param """ token = request.args.get('token') validate_token(token) data = User.get_user_all() return response_ok_list(data)