Spaces:
Sleeping
Sleeping
Download src/tests/runtime/test_fast_webapp_preview.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 2.61 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/tests/runtime/test_fast_webapp_preview.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/tests/runtime/test_fast_webapp_preview.py
-
curl -L -o test_fast_webapp_preview.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/tests/runtime/test_fast_webapp_preview.py
2.61 kB
| """A previously verified static page opens without a redundant VM boot.""" | |
| import unittest | |
| from pathlib import Path | |
| from types import SimpleNamespace | |
| from src.apps.workbench.agent_sandboxes import AgentSandboxPool | |
| from src.modules.execution.scenarios import webapp | |
| from src.modules.skill.domain.models import SkillError,digest | |
| from src.tests.runtime.fixtures import workspace | |
| class FastPagePreviewTests(unittest.TestCase): | |
| def test_verified_page_is_immediate_owner_bound_and_has_no_java_rpc(self): | |
| folder=Path(self.enterContext(workspace())) | |
| image='zkcoding-qemu@sha256:'+'0'*64 | |
| config=webapp.scenario(image);source={'files':{'website/index.html':'<html>扫雷</html>'}} | |
| source['source_digest']=digest(source['files']) | |
| candidate={'source_digest':source['source_digest'],'image':image, | |
| 'config_digest':digest(config),'classes_digest':'a'*64,'execution_mode':'qemu'} | |
| test={'stage':'test','passed':True,'passed_cases':3,'suite_digest':'suite-1'} | |
| preview={'stage':'preview','passed':True} | |
| evidence={'manifest':{'source':source,'snapshot':{'framework':{}},'candidate':candidate,'test':test,'preview':preview}} | |
| checked=[] | |
| harness=SimpleNamespace(files=lambda *args:checked.append('source'), | |
| evidence=lambda *args:checked.append(args[2])) | |
| runtime=SimpleNamespace(harness=harness,sandbox=SimpleNamespace(config=config,suite_digest='suite-1')) | |
| engine=SimpleNamespace(root=folder,runtimes={'webapp':runtime},preview_origin='http://127.0.0.1:8791', | |
| evidence=lambda actor,kind,reference:('webapp','run',evidence),spec=lambda actor,scenario:None) | |
| actor=SimpleNamespace(user_id='one');other=SimpleNamespace(user_id='two') | |
| pool=AgentSandboxPool(engine,factory=lambda *args: self.fail('VM must not start for verified page')) | |
| state=pool.start(actor,'example','webapp') | |
| self.assertEqual(state['status'],'ready') | |
| self.assertEqual(state['backend'],'verified-static-page') | |
| self.assertEqual(state['receipt']['source_digest'],source['source_digest']) | |
| self.assertEqual(checked,['source','test','preview']) | |
| self.assertEqual(pool.start(actor,'example','webapp')['id'],state['id']) | |
| with self.assertRaises(SkillError):pool.state(other,state['id']) | |
| with self.assertRaises(SkillError):pool.request(actor,state['id'],'GET','/health','Bearer test') | |
| pool.close(actor,state['id']) | |
| self.assertEqual(pool.state(actor,state['id'])['status'],'closed') | |
| if __name__=='__main__':unittest.main() | |