Class-Corder / tests / test_quiz.py
test_quiz.py
Raw
import pytest
from streamlit.testing.v1 import AppTest

def test_quiz_not_created_without_name():
    at = AppTest.from_file(script_path="auth.py", default_timeout=60)
    at.session_state.status = "verified"
    at.session_state.username = "test"
    at.session_state.lecture_id = '123'
    at.session_state.transcript = "This is a sample lecture transcript."
    at.run()
    at.switch_page("pages/quiz.py").run()
    at.button[0].click().run()
    assert at.session_state.quiz_id == ''

def test_quiz_gets_created():
    at = AppTest.from_file(script_path="auth.py", default_timeout=60)
    at.session_state.status = "verified"
    at.session_state.username = "test"
    at.session_state.lecture_id = '123'
    at.session_state.transcript = "This is a sample lecture transcript."
    at.run()
    at.switch_page("pages/quiz.py").run()
    at.text_input[0].input('Test')
    at.button[0].click().run()
    assert at.session_state.quiz_id != ''