decomposer: generate deliverable files for Inspect the single_agent template and target repository conventions to identify the required project structure, configuration, interfaces, and implementation patterns for the application landing zone agent.; Define the application landing zone agent's behavior, input and output contracts, document-generation workflow, and architecture-diagram requirements using the extracted template conventions.; Validate the implemented application_landing_zone_agent by running repository tests and checking the TSD document generation, draw.io diagram generation, agent packaging, configuration, and committed implementation against the defined contracts.; Commit and push the validated application_landing_zone_agent implementation to the target repository.
This commit is contained in:
@@ -1,31 +1,32 @@
|
||||
import json, tempfile, unittest
|
||||
from pathlib import Path
|
||||
from landing_zone_agent.generator import generate
|
||||
from landing_zone_agent.validation import validate_requirements
|
||||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
from application_landing_zone_agent import ApplicationLandingZoneAgent
|
||||
|
||||
class AgentTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.req = {"application_name":"Demo", "business_context":"Demo service", "environments":["dev","prod"], "data_classification":"internal", "availability_target":"99.9%", "components":["API","DB"]}
|
||||
|
||||
def test_generates_tsd_and_drawio(self):
|
||||
result = generate(self.req)
|
||||
self.assertIn("# Technical Solution Design: Demo", result["tsd"])
|
||||
self.assertIn("Security, resilience, and operations", result["tsd"])
|
||||
self.assertTrue(result["drawio"].startswith("<mxfile"))
|
||||
self.assertIn("<mxGraphModel>", result["drawio"])
|
||||
self.assertTrue(result["manifest"]["validation"]["drawio"])
|
||||
def payload():
|
||||
return {"application_name": "Demo <Portal>", "business_objective": "Serve users", "environments": ["dev", "prod"], "requirements": ["R1"]}
|
||||
|
||||
def test_missing_field_is_actionable(self):
|
||||
with self.assertRaisesRegex(ValueError, "data_classification"):
|
||||
validate_requirements({**self.req, "data_classification": ""})
|
||||
|
||||
def test_cli_writes_contract_files(self):
|
||||
from landing_zone_agent.cli import main
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
req_path = Path(directory) / "req.json"; out = Path(directory) / "out"
|
||||
req_path.write_text(json.dumps(self.req), encoding="utf-8")
|
||||
self.assertEqual(main(["--requirements", str(req_path), "--output-dir", str(out)]), 0)
|
||||
self.assertEqual({p.name for p in out.iterdir()}, {"tsd.md", "architecture.drawio", "manifest.json"})
|
||||
def test_generates_all_artifacts(tmp_path):
|
||||
result = ApplicationLandingZoneAgent().generate(payload(), tmp_path)
|
||||
assert (tmp_path / "tsd.md").exists()
|
||||
assert "Demo <Portal>" in result.tsd
|
||||
assert "## 5. Security" in result.tsd
|
||||
assert (tmp_path / "manifest.json").exists()
|
||||
ET.fromstring(result.diagram)
|
||||
assert "mxGraphModel" in result.diagram
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
def test_input_validation(tmp_path):
|
||||
try:
|
||||
ApplicationLandingZoneAgent().generate({"application_name": "x"}, tmp_path)
|
||||
except ValueError as exc:
|
||||
assert "business_objective" in str(exc)
|
||||
else:
|
||||
raise AssertionError("invalid input accepted")
|
||||
|
||||
|
||||
def test_manifest_is_json(tmp_path):
|
||||
ApplicationLandingZoneAgent().generate(payload(), tmp_path)
|
||||
manifest = json.loads((tmp_path / "manifest.json").read_text())
|
||||
assert set(manifest["artifacts"]) == {"tsd", "drawio"}
|
||||
|
||||
Reference in New Issue
Block a user