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

def test_no_interaction():
    at = AppTest.from_file(script_path="pages/dashboard.py", default_timeout=60)
    at.session_state.status = "verified"
    at.session_state.username = "test"
    at.run()
    assert at.session_state.status == "verified"
    assert at.session_state.username == "test"
    assert at.session_state.audio_file is None
    assert at.session_state.audio_file_name == ""
    assert at.session_state.audio_language == "en-US"
    assert at.session_state.transcript == ""
    assert at.session_state.title == ""
    assert at.session_state.summary == ""
    assert at.session_state.imagen_prompt == ""
    assert at.session_state.created_at == ""
    assert at.session_state.thumbnail_filename is None
    assert at.session_state.lectures == []
    assert at.session_state.updateSidebar is False
    assert len(at.radio) == 1
    assert len(at.button) == 1
    assert len(at.selectbox) == 1
    assert len(at.error) == 0
    assert len(at.success) == 0

def test_upload_without_audio():
    at = AppTest.from_file(script_path="pages/dashboard.py", default_timeout=60)
    at.session_state.status = "verified"
    at.session_state.username = "test"
    at.run()
    at.button[0].click().run()
    assert at.session_state.status == "verified"
    assert at.session_state.username == "test"
    assert at.session_state.audio_file is None
    assert at.session_state.audio_file_name == ""
    assert at.session_state.audio_language == "en-US"
    assert at.session_state.transcript == ""
    assert at.session_state.title == ""
    assert at.session_state.summary == ""
    assert at.session_state.imagen_prompt == ""
    assert at.session_state.created_at == ""
    assert at.session_state.thumbnail_filename is None
    assert at.session_state.lectures == []
    assert at.session_state.updateSidebar is False
    assert len(at.radio) == 1
    assert len(at.button) == 1
    assert len(at.selectbox) == 1
    assert len(at.error) == 1
    assert len(at.success) == 0
    
def test_search_without_lectures():
    at = AppTest.from_file(script_path="pages/dashboard.py", default_timeout=60)
    at.session_state.status = "verified"
    at.session_state.username = "test"
    at.run()
    at.text_input[0].input("test").run()
    assert at.text_input[0].value == "test"
    assert at.session_state.status == "verified"
    assert at.session_state.username == "test"
    assert at.session_state.audio_file is None
    assert at.session_state.audio_file_name == ""
    assert at.session_state.audio_language == "en-US"
    assert at.session_state.transcript == ""
    assert at.session_state.title == ""
    assert at.session_state.summary == ""
    assert at.session_state.imagen_prompt == ""
    assert at.session_state.created_at == ""
    assert at.session_state.thumbnail_filename is None
    assert at.session_state.lectures == []
    assert at.session_state.updateSidebar is False
    assert len(at.radio) == 1
    assert len(at.button) == 1
    assert len(at.selectbox) == 1
    assert len(at.error) == 0
    assert len(at.success) == 0