55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import pathlib
|
|
import re
|
|
import unittest
|
|
|
|
ROOT = pathlib.Path(__file__).parents[1]
|
|
|
|
|
|
def get_artifact_text(filename):
|
|
search_dirs = [
|
|
ROOT / "deliverables" / "as-is",
|
|
ROOT / "deliverables" / "target",
|
|
ROOT / "deliverables" / "validation",
|
|
ROOT / "deliverables" / "guides",
|
|
ROOT / "deliverables",
|
|
ROOT / "docs",
|
|
ROOT,
|
|
]
|
|
for d in search_dirs:
|
|
candidate = d / filename
|
|
if candidate.is_file():
|
|
return candidate.read_text(encoding="utf-8")
|
|
raise FileNotFoundError(f"Artifact {filename} not found")
|
|
|
|
|
|
class ArtifactTests(unittest.TestCase):
|
|
def test_requirements_defer_products(self):
|
|
text = get_artifact_text("requirements.md")
|
|
self.assertIn("Product selection deferred:", text)
|
|
self.assertIn("Open questions", text)
|
|
|
|
def test_architecture_has_products_and_flow(self):
|
|
text = get_artifact_text("architecture.md")
|
|
for product in ("Cloud Run", "Pub/Sub", "Cloud Storage", "Firestore"):
|
|
self.assertIn(product, text)
|
|
|
|
def test_mermaid_is_flowchart(self):
|
|
text = get_artifact_text("architecture.mmd")
|
|
self.assertTrue(text.startswith("flowchart"))
|
|
self.assertIn("Cloud Run", text)
|
|
|
|
def test_terraform_root_is_complete(self):
|
|
main = (ROOT / "terraform/main.tf").read_text()
|
|
self.assertIn("google_cloud_run_v2_service", main)
|
|
self.assertIn("google_pubsub_topic", main)
|
|
self.assertNotRegex(main, r"(?i)(password|secret|private_key)\\s*=")
|
|
|
|
def test_guide_packages_outputs(self):
|
|
guide = get_artifact_text("solution-architecture-guide.md")
|
|
for heading in ("Requirements", "Architecture", "Terraform", "Validation", "Verification"):
|
|
self.assertIn(heading, guide)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|