def testGetQuestions(self): survey_id = connection.execute(survey_table.select().where( survey_table.c.survey_title == 'test_title')).first().survey_id questions = get_questions(connection, survey_id, email='test_email') self.assertGreater(questions.rowcount, 0) auth_user_id = get_auth_user_by_email(connection, 'test_email').auth_user_id questions = get_questions(connection, survey_id, auth_user_id=auth_user_id) self.assertGreater(questions.rowcount, 0) self.assertRaises(TypeError, get_questions, connection, survey_id) self.assertRaises(TypeError, get_questions, connection, survey_id, auth_user_id='', email='')
def get_question_stats(connection: Connection, survey_id: str, auth_user_id: str=None, email: str=None) -> list: """ Returns a JSON-y list of dicts containing statistics about submissions to the questions in the given survey. :param connection: a SQLAlchemy Connection :param survey_id: the UUID of the survey :param auth_user_id: the UUID of the user :param email: the e-mail address of the user :return: a list containing the results """ user_id = _get_user_id(connection, auth_user_id, email) questions = get_questions(connection, survey_id, user_id, None) return json_response( list(_get_question_stats(connection, questions, user_id, None)))