|
16 | 16 |
|
17 | 17 | pytestmark = pytest.mark.api |
18 | 18 |
|
19 | | -# Shared mock target |
| 19 | +# Shared mock targets |
20 | 20 | RUN_CONVERSATION = "app.api.widget.run_conversation" |
| 21 | +SETTINGS = "app.api.widget.settings" |
21 | 22 |
|
22 | 23 |
|
23 | 24 | @pytest.fixture |
@@ -89,8 +90,10 @@ def test_404_for_unknown_widget(self, client): |
89 | 90 | class TestInitGuestSession: |
90 | 91 | """Tests for POST /widgets/guest/session/init/{public_widget_id}.""" |
91 | 92 |
|
| 93 | + @patch(SETTINGS) |
92 | 94 | @patch(RUN_CONVERSATION, new_callable=AsyncMock, return_value="Hello from AI") |
93 | | - def test_init_session_with_first_message(self, mock_ai, client, db_session, widget_env): |
| 95 | + def test_init_session_with_first_message(self, mock_ai, mock_settings, client, db_session, widget_env): |
| 96 | + mock_settings.GOOGLE_API_KEY = "test-key" |
94 | 97 | widget = widget_env["widget"] |
95 | 98 | guest = GuestUserFactory(widget=widget, widget_id=widget.id) |
96 | 99 | db_session.commit() |
@@ -150,8 +153,10 @@ def test_init_404_unknown_guest(self, client, widget_env): |
150 | 153 | class TestChatInSession: |
151 | 154 | """Tests for POST /widgets/chat/{public_widget_id}/session/{session_id}.""" |
152 | 155 |
|
| 156 | + @patch(SETTINGS) |
153 | 157 | @patch(RUN_CONVERSATION, new_callable=AsyncMock, return_value="AI reply") |
154 | | - def test_send_message(self, mock_ai, client, db_session, widget_env): |
| 158 | + def test_send_message(self, mock_ai, mock_settings, client, db_session, widget_env): |
| 159 | + mock_settings.GOOGLE_API_KEY = "test-key" |
155 | 160 | widget = widget_env["widget"] |
156 | 161 | guest = GuestUserFactory(widget=widget, widget_id=widget.id) |
157 | 162 | session = ChatSessionFactory(guest=guest, guest_id=guest.id) |
|
0 commit comments