File size: 1,068 Bytes
748e8a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
    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