def test_get_user_by_id(): """a user can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) user_id = store.create_user(quiz_id, "Someone", False) user = store.get_user_by_id(user_id) assert user
def test_get_question(): """questions can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question_from_source(quiz_id) question = store.get_question_by_id(question_id) assert question
def test_create_user(): """a user can be added to the store and quiz""" store = Store() quiz_id = store.create_quiz(FakeSource) user_id = store.create_user(quiz_id, "Someone", False) user = store.users[user_id] assert user
def test_create_question_from_real_source_with_category_hard(): """questions can be added form a source""" store = Store() quiz_id = store.create_quiz(OpenTDB, difficulty="hard", category=18) question_id = store.create_question_from_source(quiz_id) question = store.questions[question_id] assert question
def test_create_question_from_fake_source(): """questions can be added form a source""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question_from_source(quiz_id) question = store.questions[question_id] assert question
def test_create_question_from_real_source(): """questions can be added form a source""" store = Store() quiz_id = store.create_quiz(OpenTDB) question_id = store.create_question_from_source(quiz_id) question = store.questions[question_id] assert question
def test_get_answer_by_id(): """answers can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question_from_source(quiz_id) answer_id = store.create_answer(question_id, "some answer text", True) answer = store.get_answer_by_id(answer_id) assert answer
def test_create_answer(): """answers can be added to a app and quiz""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question_from_source(quiz_id) answer_id = store.create_answer(question_id, "some answer text", True) answer = store.answers[answer_id] assert answer
def test_create_question(): """questions can be added to a app and quiz""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question( quiz_id, {"text": "some question", "difficulty": "medium", "category": "some category"}) question = store.questions[question_id] assert question
def test_get_users_by_id(): """answers can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) user_id_one = store.create_user(quiz_id, "Someone", False) user_id_two = store.create_user(quiz_id, "Someone", False) users = store.get_users_by_id([user_id_one, user_id_two]) assert type(users) is list
def test_get_answers_by_id(): """answers can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) question_id = store.create_question_from_source(quiz_id) answer_id_one = store.create_answer( question_id, "some answer text", True) answer_id_two = store.create_answer( question_id, "some answer text", False) answers = store.get_answers_by_id([answer_id_one, answer_id_two]) assert type(answers) is list
def filled_store(): """Creates a somewhat larger app to test that no extra things are added""" store = Store() quiz_count = 0 question_count = 0 user_count = 0 for _ in range(3): quiz_id = store.create_quiz(FakeSource) quiz_count += 1 for _ in range(5): store.create_question_from_source(quiz_id) question_count += 1 for _ in range(8): store.create_user(quiz_id, "Someone", False) user_count += 1 return store
def test_create_quiz(): """quizes can be created""" store = Store() quiz_id = store.create_quiz(FakeSource) assert store.quizes[quiz_id]
def test_get_quiz(): """quizes can be retrieved from the app""" store = Store() quiz_id = store.create_quiz(FakeSource) quiz = store.get_quiz_by_id(quiz_id) assert quiz