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

def test_no_chat_entered():
    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 = "test_lecture_id"
    at.session_state.title = "Test title"
    at.session_state.summary = "Test summary"
    at.session_state.transcript = "Test transcript"
    at.session_state.thumbnail_filename = "test_filename.jpeg"
    at.switch_page("pages/chat.py").run()
    at.session_state.current_chat_id = ''
    at.session_state.show_new_chat_form = False

    assert at.session_state.status == "verified"
    assert at.session_state.status == "verified"
    assert at.session_state.lecture_id == "test_lecture_id"
    assert at.session_state.title == "Test title"
    assert at.session_state.summary == "Test summary"
    assert at.session_state.transcript == "Test transcript"
    assert at.session_state.thumbnail_filename == "test_filename.jpeg"
    assert at.session_state.current_chat_id == ''
    assert at.session_state.show_new_chat_form == False

def test_chat_entered():
    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 = "test_lecture_id"
    at.session_state.title = "Test title"
    at.session_state.summary = "Test summary"
    at.session_state.transcript = "Test transcript"
    at.session_state.thumbnail_filename = "test_filename.jpeg"
    at.switch_page("pages/chat.py").run()
    at.session_state.current_chat_id = "test_chat_id"
    at.session_state.show_new_chat_form = True

    assert at.session_state.status == "verified"
    assert at.session_state.status == "verified"
    assert at.session_state.lecture_id == "test_lecture_id"
    assert at.session_state.title == "Test title"
    assert at.session_state.summary == "Test summary"
    assert at.session_state.transcript == "Test transcript"
    assert at.session_state.thumbnail_filename == "test_filename.jpeg"
    assert at.session_state.current_chat_id == "test_chat_id"
    assert at.session_state.show_new_chat_form == True