| import streamlit.testing as stt | |
| # Define a test case for adding a person | |
| def test_add_person(): | |
| # Simulate user input | |
| with stt.install_test_input(): | |
| stt.test_runner.start("app.py") # Path to your Streamlit script | |
| # Select the "Add Person" option | |
| stt.test_input("Select Option", "Add Person") | |
| # Enter name, image path, and Instagram handle | |
| stt.test_input("Enter Name", "John Doe") | |
| stt.test_input("Upload Image", "random.jpg") # Path to your test image | |
| stt.test_input("Enter Instagram Handle", "johndoe123") | |
| # Click the "Add Person" button | |
| stt.test_input("Add Person") | |
| # Verify the success message | |
| stt.test_output("Success: John Doe added to the database!") | |
| # Clean up | |
| stt.test_runner.cleanup() | |
| # Run the test case | |
| test_add_person() |