Test that basic messaging works.
()
| 142 | print(f" [{i}] {role}{suffix}: {text}...") |
| 143 | |
| 144 | def test_basic_message(): |
| 145 | """Test that basic messaging works.""" |
| 146 | print("\n" + "="*60) |
| 147 | print("TEST: Basic message (no interrupt)") |
| 148 | print("="*60) |
| 149 | |
| 150 | session_id = create_test_session() |
| 151 | if not session_id: |
| 152 | print("❌ Failed to create session") |
| 153 | return False |
| 154 | print(f"Created session: {session_id}") |
| 155 | |
| 156 | try: |
| 157 | result_q = queue_mod.Queue() |
| 158 | thread = threading.Thread( |
| 159 | target=send_message_async, |
| 160 | args=("What is 2+2? Just answer with the number.", session_id, result_q) |
| 161 | ) |
| 162 | thread.start() |
| 163 | thread.join(timeout=120) |
| 164 | |
| 165 | if thread.is_alive(): |
| 166 | print("❌ Message timed out") |
| 167 | return False |
| 168 | |
| 169 | ok, output = result_q.get() |
| 170 | if not ok: |
| 171 | print(f"❌ Message failed: {output[:200]}") |
| 172 | return False |
| 173 | |
| 174 | print(f"Response: {output[:100]}...") |
| 175 | |
| 176 | history = get_history(session_id) |
| 177 | roles = [m.get('role') for m in history] |
| 178 | print(f"Roles: {roles}") |
| 179 | |
| 180 | if roles == ['user', 'assistant']: |
| 181 | print("✅ Basic message works") |
| 182 | return True |
| 183 | else: |
| 184 | print(f"❌ Unexpected roles: {roles}") |
| 185 | return False |
| 186 | |
| 187 | finally: |
| 188 | destroy_session(session_id) |
| 189 | |
| 190 | def test_soft_interrupt_during_streaming(): |
| 191 | """ |
nothing calls this directly
no test coverage detected