Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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