保存今天的修改

This commit is contained in:
songxinnuo
2026-11-02 17:51:10 +08:00
parent 04f94ad665
commit eebaba8084
44 changed files with 2831 additions and 154 deletions
+5 -2
View File
@@ -8,6 +8,7 @@ from unittest.mock import patch
from datetime import datetime
from logistics_chat import create_app, db
from staff_fixture import login_staff
class VisitorTests(unittest.TestCase):
@@ -18,6 +19,8 @@ class VisitorTests(unittest.TestCase):
self.app = create_app({'TESTING':True, 'DATABASE':root/'history.db', 'UPLOAD_DIR':root/'uploads',
'BACKUP_DIR':root/'backups','LOG_DIR':root/'logs','DEEPSEEK_API_KEY':'','RATE_LIMIT_PER_MIN':1000})
self.a, self.b = self.app.test_client(), self.app.test_client()
self.staff = self.app.test_client()
login_staff(self.app, self.staff)
for client, key in ((self.a,'1'*64),(self.b,'2'*64)):
self.assertEqual(client.post('/api/visitor/session',json={'key':key}).status_code,200)
@@ -96,7 +99,7 @@ class VisitorTests(unittest.TestCase):
for action in ('send','close'):
self.assertEqual(self.b.post('/api/visitor/human/'+action,json={'sid':sid,'content':'attack'}).status_code,404)
self.assertEqual(self.a.post('/api/visitor/human/send',json={'sid':sid,'side':'agent','content':'fake agent'}).status_code,403)
self.a.post('/api/human/note',json={'sid':sid,'note':'STAFF_PRIVATE'})
self.assertEqual(self.staff.post('/api/human/note',json={'sid':sid,'note':'STAFF_PRIVATE'}).status_code,200)
response=self.a.get(f'/api/visitor/human/poll?sid={sid}')
self.assertNotIn('note',response.json)
self.assertNotIn('STAFF_PRIVATE',response.get_data(as_text=True))
@@ -115,7 +118,7 @@ class VisitorTests(unittest.TestCase):
root=Path(self.app.config['UPLOAD_DIR'])
(root/'legacy.txt').write_text('LEGACY_PRIVATE')
self.assertEqual(self.a.get('/uploads/legacy.txt').status_code,404)
with self.a.get('/api/staff'+url) as staff:
with self.staff.get('/api/staff'+url) as staff:
self.assertEqual(staff.data,b'A_PRIVATE')
def test_guest_keys_and_client_claims_cannot_unlock_orders(self):