MCPcopy Create free account
hub / github.com/1jehuang/jcode / test_basic_message

Function test_basic_message

scripts/test_soft_interrupt.py:144–188  ·  view source on GitHub ↗

Test that basic messaging works.

()

Source from the content-addressed store, hash-verified

142 print(f" [{i}] {role}{suffix}: {text}...")
143
144def 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
190def test_soft_interrupt_during_streaming():
191 """

Callers

nothing calls this directly

Calls 5

create_test_sessionFunction · 0.85
get_historyFunction · 0.85
destroy_sessionFunction · 0.70
startMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected