取消ZIP材料包照片数量限制,保留文件大小校验

This commit is contained in:
2026-11-11 18:11:27 +08:00
parent e1e909d617
commit d2cb824fa2
6 changed files with 35 additions and 12 deletions
+27
View File
@@ -20,6 +20,33 @@ def package(entries=None):
class CenterExportTests(ApiTestCase):
async def test_material_with_over_100_photos_can_be_created_edited_and_downloaded(self):
owner=await register(self.client,'manyphotos');headers=auth(owner['token'])
image=io.BytesIO();Image.new('RGB',(20,20),'blue').save(image,'PNG')
raw=package([(f'照片/{i}.png',image.getvalue()) for i in range(101)])
with tempfile.TemporaryDirectory() as directory,patch.object(self.m,'_db_path',Path(directory)/'test.db'):
response=await self.client.post('/api/center/materials',headers=headers,content=raw)
self.assertEqual(response.status_code,200,response.text)
material=response.json();self.assertEqual(len(material['photo_ids']),101)
response=await self.client.post('/api/activities',headers=headers,json={
'title':'多照片一楼活动','start_at':self.m.now_ms(),'record_type':'center',
'material_id':material['id'],'photo_ids':material['photo_ids'],
})
self.assertEqual(response.status_code,200,response.text)
activity=response.json()['activity'];self.assertEqual(len(activity['photo_ids']),101)
edited=await self.client.patch('/api/activities/'+activity['id'],headers=headers,json={
'description':'更新说明','photo_ids':material['photo_ids'],
})
self.assertEqual(edited.status_code,200,edited.text)
self.assertEqual(edited.json()['activity']['photo_ids'],material['photo_ids'])
downloaded=await self.client.get('/api/center/materials/'+material['id'],headers=headers)
self.assertEqual(downloaded.status_code,200);self.assertEqual(downloaded.content,raw)
last_photo=await self.client.get('/api/center/photos/'+material['photo_ids'][-1],headers=headers)
self.assertEqual(last_photo.status_code,200)
# 同一天已有超过100张照片,也可以继续提交ZIP材料。
second=await self.client.post('/api/center/materials',headers=headers,content=package())
self.assertEqual(second.status_code,200,second.text)
async def test_api_auth_export_all_and_contact_redaction(self):
for path in ['/api/center/data','/api/center/schema','/api/center/export']:
self.assertEqual((await self.client.get(path)).status_code,401)