招聘公告按原网页顺序展示导出

This commit is contained in:
2026-12-04 15:11:09 +08:00
parent ccb05fd17e
commit 5ad49852b3
4 changed files with 25 additions and 2 deletions
+17
View File
@@ -76,3 +76,20 @@ class RecruitTests(ApiTestCase):
fetch_detail.assert_awaited_once()
detail = (await self.client.get('/api/recruit/announcements/2', headers=auth(owner['token']))).json()
self.assertIn('外贸业务员', detail['content_html'])
async def test_list_and_export_follow_source_order(self):
owner = await register(self.client, 'recruit-order')
rows = [
dict(RAW, gonggaoId=21, checkTime='2020-01-01 00:00:00'),
dict(RAW, gonggaoId=22, checkTime='2020-01-02 00:00:00'),
dict(RAW, gonggaoId=23, checkTime='2020-01-03 00:00:00'),
]
fetch = AsyncMock(return_value={"code": 0, "rows": rows, "extra": {"pages": 1}})
with patch.object(recruit, 'fetch_page', new=fetch):
await self.client.post('/api/recruit/sync', headers=auth(owner['token']))
data = (await self.client.get('/api/recruit/announcements', headers=auth(owner['token']))).json()
self.assertEqual([item['gonggao_id'] for item in data['items']], [21, 22, 23])
response = await self.client.get('/api/recruit/export', params={'ids': '23,21,22', 'format': 'markdown'}, headers=auth(owner['token']))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['X-Recruit-Export-Count'], '3')
self.assertLess(response.text.find('测试公告'), response.text.find('原文链接'))