""" test_app.py Tests the main application. """ import warnings import pytest import streamlit as st from streamlit.testing.v1 import AppTest from app import open_intake_form warnings.filterwarnings("ignore", message="missing ScriptRunContext") warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*custom tp_new.*") intake_form = [ 'candidate_name', 'candidate_contact_type', 'candidate_contact', 'candidate_dob', 'candidate_location', 'intake_submission' ] @pytest.fixture def app(): return AppTest.from_file('app.py').run() @pytest.fixture def form(): form = AppTest.from_function(open_intake_form).run() form.session_state.open_intake = True for key in intake_form: form.session_state[key] = None return form def test_new_session(app): assert 'messages' in app.session_state, f"`messages` not found in session state" def test_open_intake_button(app): # Simulate entering details app.button(key='open_intake').click() assert 'open_intake' in app.session_state