Add internal chat testing with memory diagnostics and cancellation
This commit is contained in:
@@ -92,6 +92,18 @@ class Tests(unittest.TestCase):
|
||||
with urllib.request.urlopen(req) as r:self.assertEqual(json.load(r)['port'],8120)
|
||||
configure.assert_called_once_with({'port':8120})
|
||||
|
||||
def test_chat_test_routes_are_admin_only(self):
|
||||
self.assertIsNone(self.request('chat-tests')['job'])
|
||||
for path,method,body in [('chat-tests','GET',None),('chat-tests/start','POST',b'{}')]:
|
||||
req=urllib.request.Request(self.url+'/api/v1/'+path,method=method,data=body,headers={'Authorization':'Bearer '+self.api_token,'X-Athena-Deck':'1','Content-Type':'application/json'})
|
||||
with self.assertRaises(urllib.error.HTTPError) as exc:urllib.request.urlopen(req)
|
||||
self.assertEqual(exc.exception.code,401);exc.exception.close()
|
||||
with patch.object(self.server.chat_tests,'start',return_value={'state':'running'}) as start:
|
||||
data={'profile_id':'test','messages':[{'role':'user','content':'synthetic'}],'max_tokens':8}
|
||||
req=urllib.request.Request(self.url+'/api/v1/chat-tests/start',data=json.dumps(data).encode(),headers={'Cookie':self.cookie,'X-Athena-Deck':'1','Content-Type':'application/json'})
|
||||
with urllib.request.urlopen(req) as r:self.assertEqual(json.load(r)['state'],'running')
|
||||
start.assert_called_once_with(data)
|
||||
|
||||
def test_control_guard(self):
|
||||
for headers in ({},{'X-Athena-Deck':'1','Origin':'http://evil.invalid'}):
|
||||
with self.assertRaises(urllib.error.HTTPError) as e:self.request('demo/start','POST',headers)
|
||||
|
||||
Reference in New Issue
Block a user