feat: add editable skill evaluation versions
This commit is contained in:
@@ -178,6 +178,62 @@ class EvaluationApiTests(unittest.TestCase):
|
||||
self.assertIn('text/csv', export.headers['content-type'])
|
||||
self.assertIn('导航去公司', export.content.decode('utf-8-sig'))
|
||||
|
||||
def test_skill_version_endpoints(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
state = _build_state(root)
|
||||
with TestClient(create_app(state)) as client:
|
||||
versions_response = client.get(
|
||||
'/api/evaluations/skills/label-master/versions',
|
||||
params={'account_id': 'alice'},
|
||||
)
|
||||
self.assertEqual(versions_response.status_code, 200)
|
||||
versions = versions_response.json()
|
||||
current_id = versions['current_snapshot_id']
|
||||
|
||||
manifest = client.get(
|
||||
(
|
||||
'/api/evaluations/skills/label-master/versions/'
|
||||
f'{current_id}'
|
||||
),
|
||||
params={'account_id': 'alice'},
|
||||
)
|
||||
self.assertEqual(manifest.status_code, 200)
|
||||
self.assertTrue(
|
||||
any(
|
||||
item['path'] == 'SKILL.md'
|
||||
for item in manifest.json()['files']
|
||||
)
|
||||
)
|
||||
|
||||
file_response = client.get(
|
||||
(
|
||||
'/api/evaluations/skills/label-master/versions/'
|
||||
f'{current_id}/file'
|
||||
),
|
||||
params={'account_id': 'alice', 'path': 'SKILL.md'},
|
||||
)
|
||||
self.assertEqual(file_response.status_code, 200)
|
||||
content = file_response.json()['content'].replace(
|
||||
'Use the label catalog.',
|
||||
'Use the label catalog carefully.',
|
||||
)
|
||||
saved_response = client.post(
|
||||
'/api/evaluations/skills/label-master/versions',
|
||||
json={
|
||||
'account_id': 'alice',
|
||||
'base_snapshot_id': current_id,
|
||||
'version_name': '测试版本',
|
||||
'note': 'API 测试',
|
||||
'files': {'SKILL.md': content},
|
||||
},
|
||||
)
|
||||
self.assertEqual(saved_response.status_code, 200)
|
||||
self.assertEqual(
|
||||
saved_response.json()['version_name'],
|
||||
'测试版本',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user