24 lines
1.3 KiB
Python
24 lines
1.3 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
from persona_resolver import resolve_persona, DEFAULT_VOICE_ID
|
|
|
|
|
|
class PersonaTests(unittest.TestCase):
|
|
def test_yangmi_authorized_voice_new_context_and_rules(self):
|
|
import json
|
|
vid=json.loads(Path('.runtime/personas/yangmi_fiction.json').read_text())['voice_id']
|
|
p=resolve_persona(Path('.'),'yangmi_fiction',[vid])
|
|
self.assertEqual(p['voice_id'],vid)
|
|
self.assertTrue(p['fresh_conversation']);self.assertTrue(p['locked'])
|
|
self.assertIn('北京',p['rules']);self.assertNotIn('奉先',p['rules'])
|
|
self.assertNotIn('https://',p['rules']);self.assertLessEqual(len(p['rules']),1400)
|
|
for value in ['北京','演员','旁白']:self.assertIn(value,p['rules'])
|
|
|
|
def test_lvbu_unchanged_and_unknown_rejected(self):
|
|
import json
|
|
vid=json.loads(Path('.runtime/personas/lvbu.json').read_text())['voice_id']
|
|
p=resolve_persona('.','lvbu',[vid]);self.assertEqual(p['voice_id'],vid);self.assertIn('奉先',p['rules']);self.assertNotIn('杨密',p['rules'])
|
|
for value in ['unknown','../lvbu',None]:
|
|
with self.assertRaises(ValueError):resolve_persona('.',value,[vid])
|
|
with self.assertRaises(ValueError):resolve_persona('.','yangmi_fiction',[])
|