Create test_chat_box.py
Browse files- tests/test_chat_box.py +21 -0
tests/test_chat_box.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from your_module.components.chat_box import chat_box
|
| 2 |
+
import unittest
|
| 3 |
+
from unittest.mock import MagicMock
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
+
class TestChatBox(unittest.TestCase):
|
| 7 |
+
|
| 8 |
+
def test_chat_box_renders_correctly(self):
|
| 9 |
+
session_state_mock = MagicMock()
|
| 10 |
+
config_mock = {"chat_key": "value"}
|
| 11 |
+
|
| 12 |
+
# Mocking Streamlit's text input
|
| 13 |
+
st.text_input = MagicMock()
|
| 14 |
+
|
| 15 |
+
chat_box(session_state_mock, config_mock)
|
| 16 |
+
|
| 17 |
+
# Assert that the text_input function was called
|
| 18 |
+
st.text_input.assert_called_with("Enter your message:")
|
| 19 |
+
|
| 20 |
+
if __name__ == '__main__':
|
| 21 |
+
unittest.main()
|