OSINT_Tool / tests /test_sidebar.py
Canstralian's picture
Create test_sidebar.py
6cbf8e4 verified
raw
history blame contribute delete
735 Bytes
import streamlit as st
import unittest
from unittest.mock import MagicMock
from your_module.components.sidebar import sidebar
class TestSidebar(unittest.TestCase):
def test_sidebar_renders_correctly(self):
# Mocking Streamlit session state and config
session_state_mock = MagicMock()
config_mock = {"sidebar_key": "value"}
# Run the sidebar function
sidebar(session_state_mock, config_mock)
# Check if the sidebar rendered specific components (for example, a slider)
# You can assert that Streamlit functions are called as expected
st.sidebar.slider.assert_called_with("Slider", min_value=0, max_value=10, value=5)
if __name__ == '__main__':
unittest.main()