Spaces:
Sleeping
Sleeping
Download src/tests/runtime/test_requirement_business.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/tests/runtime/test_requirement_business.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/tests/runtime/test_requirement_business.py
-
curl -L -o test_requirement_business.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/tests/runtime/test_requirement_business.py
3.28 kB
| """Business profiles bind only technical limits, not a purchase-specific UI.""" | |
| import unittest | |
| from src.modules.execution.scenarios import business_app | |
| from src.modules.harness.policy import Harness | |
| from src.modules.skill.domain.models import SkillError | |
| from src.modules.skill.packs.examples import framework_candidate | |
| from src.modules.orchestrator.service import AgentRuntime | |
| class RequirementBusinessTests(unittest.TestCase): | |
| def setUp(self): | |
| self.profile=framework_candidate().model_copy(update={'profile_id':business_app.PROFILE, | |
| 'allowed_paths':['src/main/','website/'],'state':'approved'}).model_dump() | |
| self.harness=Harness(enabled=True,allow_qemu=True) | |
| def test_model_can_supply_business_java_and_matching_html(self): | |
| page='<html><style>body{color:blue}</style><h1>物流单</h1><script>window.zkRequest("GET","/api/app/list")</script></html>' | |
| source=self.harness.files({'files':{business_app.JAVA:'class App {}',business_app.PAGE:page}},self.profile) | |
| self.assertEqual(source['files'][business_app.PAGE],page) | |
| self.assertEqual(source['files'][business_app.JAVA],'class App {}') | |
| def test_generated_page_cannot_bypass_controlled_bridge(self): | |
| page='<html><style></style><script>fetch("/api/admin")</script></html>' | |
| with self.assertRaises(SkillError): | |
| self.harness.files({'files':{business_app.JAVA:'class App {}',business_app.PAGE:page}},self.profile) | |
| def test_recovery_reuses_original_design_without_model_call(self): | |
| from unittest.mock import Mock | |
| runtime=object.__new__(AgentRuntime);runtime.store=Mock();runtime.llm=Mock() | |
| original={'summary':'物流单、查询与处理;其余为待确认假设'} | |
| run={'id':'recovery','request':{'preserved_design':original}} | |
| result=runtime._handle(None,run,{'operation_id':'AO04'}, {}, lambda:False) | |
| self.assertEqual(result,{'design':original}) | |
| runtime.llm.generate.assert_not_called() | |
| runtime.store.stage_event.assert_called_once() | |
| def test_java_recovery_keeps_verified_original_page_and_cannot_bypass_file_gates(self): | |
| page='<html><style></style><h1>物流单</h1><script>window.zkRequest("GET","/api/app/list")</script></html>' | |
| run={'snapshot':{'framework':self.profile},'request':{'recovery_diagnostics':{'error':'JAVA_TEST_FAILED'}, | |
| 'baseline':{'files':{business_app.JAVA:'old Java',business_app.PAGE:page}}}} | |
| partial={'files':{business_app.JAVA:'fixed Java'}} | |
| merged=AgentRuntime._candidate_patch(run,partial) | |
| self.assertEqual(merged['files'],{business_app.JAVA:'fixed Java',business_app.PAGE:page}) | |
| self.harness.files(merged,self.profile) | |
| del run['request']['recovery_diagnostics'] | |
| with self.assertRaises(SkillError):self.harness.files(AgentRuntime._candidate_patch(run,partial),self.profile) | |
| run.update(repair_pending=True,release={'draft':{'graph':{'nodes':[{'id':'patch','operation_ref':'AO06@0.1.0'}]}}}, | |
| outputs={'patch':{'source':{'files':{business_app.JAVA:'old Java',business_app.PAGE:page}}}}) | |
| self.assertEqual(AgentRuntime._candidate_patch(run,partial)['files'][business_app.PAGE],page) | |
| if __name__=='__main__':unittest.main() | |