Spaces:
Running
Running
Create test_sidebar.py
Browse files- tests/test_sidebar.py +21 -0
tests/test_sidebar.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import unittest
|
3 |
+
from unittest.mock import MagicMock
|
4 |
+
from your_module.components.sidebar import sidebar
|
5 |
+
|
6 |
+
class TestSidebar(unittest.TestCase):
|
7 |
+
|
8 |
+
def test_sidebar_renders_correctly(self):
|
9 |
+
# Mocking Streamlit session state and config
|
10 |
+
session_state_mock = MagicMock()
|
11 |
+
config_mock = {"sidebar_key": "value"}
|
12 |
+
|
13 |
+
# Run the sidebar function
|
14 |
+
sidebar(session_state_mock, config_mock)
|
15 |
+
|
16 |
+
# Check if the sidebar rendered specific components (for example, a slider)
|
17 |
+
# You can assert that Streamlit functions are called as expected
|
18 |
+
st.sidebar.slider.assert_called_with("Slider", min_value=0, max_value=10, value=5)
|
19 |
+
|
20 |
+
if __name__ == '__main__':
|
21 |
+
unittest.main()
|