import unittest from execution_setup import assess from profiles import QWEN_REPO,FLUX_REPO from tts_runtime import REPO,REVISION class ExecutionSetupTests(unittest.TestCase): def check(self,kind,repo,file,installed=None,**extra):return assess(dict(kind=kind,repo=repo,file=file,**extra),installed or {}) def test_unknown_and_asr_not_llama(self): for kind in ['stt','music','voice','video','image','audio']: self.assertEqual(self.check(kind,'other/model','model.gguf')['state'],'unsupported') def test_images_reuse_runtime_but_need_components(self): for repo,file in [(QWEN_REPO,'model.gguf'),(FLUX_REPO,'Flux.2 Klein-9B_fp16_nsfw.safetensors')]: r=self.check('image',repo,file,{'image':True});self.assertEqual(r['state'],'setup');self.assertEqual(len(r['components']),2) self.assertEqual(self.check('image',repo,file)['state'],'runtime_missing') def test_tts_exact_revision_no_silent_replacement(self): self.assertEqual(self.check('audio',REPO,'model.safetensors',revision=REVISION)['state'],'runtime_missing') self.assertEqual(self.check('audio',REPO,'model.safetensors',revision='other')['state'],'unsupported') self.assertIn('alternative',self.check('audio','mlx-community/base','model.safetensors')) def test_components(self): for file in ['mmproj.gguf','vae/model.safetensors','speech_tokenizer/model.safetensors','config.json']: self.assertEqual(self.check('audio',REPO,file)['state'],'component') def test_chat_is_candidate_not_guarantee(self): self.assertEqual(self.check('chat','a/b','model.gguf',{'chat':True})['state'],'check') self.assertEqual(self.check('chat','a/b','model.safetensors')['state'],'unsupported') def test_profile_blockers_and_ready(self): model=dict(kind='image',repo=QWEN_REPO,file='model.gguf') self.assertEqual(assess(model,{'image':True},dict(runnable=False,blockers=['VAE fehlt']))['state'],'profile_incomplete') self.assertEqual(assess(model,{'image':True},dict(runnable=True))['state'],'ready') def test_hub_image_family_reuses_installed_runtime_without_claiming_execution(self): model=dict(kind='image',repo='other/new-image',file='weights.safetensors',runtime_metadata=dict(pipeline_tag='text-to-image',library_name='diffusers',architecture='NewImagePipeline')) result=assess(model,{'image':True}) self.assertEqual(result['state'],'workflow_missing') self.assertTrue(result['installed']) self.assertEqual(result['family'],'NewImagePipeline') self.assertIn('Workflow',result['message']) self.assertEqual(assess(dict(model,kind='audio'),{'image':True})['state'],'unsupported') def test_every_category_has_explicit_unverified_candidate(self): for kind in ('chat','image','audio','stt','music','voice','video'): result=self.check(kind,'unknown/family','weights.safetensors') self.assertTrue(result['candidates']) self.assertIn('NICHT bestÃĪtigt',result['candidates'][0]['evidence']) self.assertNotEqual(result['state'],'ready') def test_yue2_gguf_recognition_does_not_claim_worker(self): result=self.check('music','audio-cpp/Yue2-3B-GGUF','yue2-3b-q8_0.gguf',{'audio_cpp':True}) self.assertEqual(result['family'],'YuE2') self.assertEqual(result['state'],'adapter_missing') self.assertTrue(result['candidates'][0]['installed']) self.assertEqual(result['candidates'][0]['route'],'#audio-cpp-runtime') self.assertTrue(result['components']) def test_component_never_offers_runtime_or_profile(self): result=self.check('music','audio-cpp/Yue2-3B-GGUF','yue2-vae-f16.gguf') self.assertEqual(result['state'],'component') self.assertEqual(result['candidates'],[])