import pathlib import unittest ROOT = pathlib.Path(__file__).resolve().parents[2] class NextPathPipelineTests(unittest.TestCase): def test_deployment_is_debian_hosted_private_and_health_checked(self): pipeline = (ROOT / "lib/jeannie/pipeline.sh").read_text(encoding="utf-8") command = (ROOT / "jeannie").read_text(encoding="utf-8") server = (ROOT / "cmd/jeannie-server/main.go").read_text(encoding="utf-8") self.assertIn("deploy_nextpath()", pipeline) self.assertIn('require_debian_server "deploy-nextpath"', pipeline) self.assertIn("GOTOOLCHAIN=local go test ./cmd/nextpath/...", pipeline) self.assertIn("NEXTPATH_ACCOUNT_STORE=${account_store}", pipeline) self.assertIn("NEXTPATH_OPPORTUNITY_STORE=${opportunity_store}", pipeline) self.assertIn("NEXTPATH_CATALOG=${catalog_store}", pipeline) self.assertIn("nextpath-catalog-refresh.py", pipeline) self.assertIn("--catalog-output /run/nextpath-refresh/catalog.json", pipeline) self.assertIn("--mapping-output /run/nextpath-refresh/catalog-mapping.json", pipeline) self.assertIn("--source-cache ${catalog_cache}", pipeline) self.assertIn("RuntimeDirectory=nextpath-refresh", pipeline) self.assertIn("/run/nextpath-refresh/opportunity.json ${opportunity_store}", pipeline) self.assertIn("LAB_NEXTPATH_CATALOG_LIMIT", pipeline) self.assertIn("nextpath-opportunity-refresh.timer", pipeline) self.assertIn("nextpath_action()", pipeline) self.assertNotIn("CareerOneStop API token", pipeline) self.assertNotIn("--token-file", pipeline) self.assertIn("Projections Central", (ROOT / "scripts/nextpath-opportunity-refresh.py").read_text()) refresh = (ROOT / "scripts/nextpath-opportunity-refresh.py").read_text() self.assertIn("arizona_education_options", refresh) self.assertIn("2024_Gaz_zcta_national.zip", refresh) self.assertIn("annual_in_state_tuition", refresh) self.assertIn("institution_completion_rate_percent", refresh) self.assertIn('print(f"Arizona education options: {programs}")', pipeline) self.assertLess( pipeline.index("nextpath-catalog-refresh.py --seed-catalog"), pipeline.index("nextpath-opportunity-refresh.py --mapping /run/nextpath-refresh/catalog-mapping.json"), ) self.assertLess( pipeline.index("systemctl start nextpath-opportunity-refresh.service"), pipeline.index("systemctl restart nextpath.service"), ) self.assertIn("ReadWritePaths=${install_dir}/data", pipeline) self.assertIn("sudo chmod 0700", pipeline) self.assertIn('legacy_account_store="${install_dir}/accounts.json"', pipeline) self.assertIn('! sudo test -e "${account_store}"', pipeline) self.assertIn('sudo mv "${legacy_account_store}" "${account_store}"', pipeline) self.assertIn('sudo cp -p "${account_store}"', pipeline) self.assertIn('"${backup_dir}/accounts-${backup_timestamp}-${release_id:0:12}.json"', pipeline) self.assertLess( pipeline.index('sudo cp -p "${account_store}"'), pipeline.index('sudo systemctl restart nextpath.service'), ) self.assertIn('curl -fsS --connect-timeout 3 "http://127.0.0.1:${http_port}/healthz"', pipeline) self.assertIn("nextpath.service", pipeline) self.assertIn("deploy-nextpath)", command) self.assertIn("nextpath)", command) self.assertIn('"deploy-nextpath": true', server) self.assertIn('"nextpath":', server) def test_inventory_declares_public_wip(self): inventory = (ROOT / "homelab.yml").read_text(encoding="utf-8") self.assertIn("nextpath.lab2025.duckdns.org", inventory) self.assertIn("install_dir: /data/homelab-nextpath", inventory) self.assertIn("http_port: 8892", inventory) def test_edge_routes_public_tls_to_the_private_backend(self): main = (ROOT / "bootstrap/edge/main.tf").read_text(encoding="utf-8") variables = (ROOT / "bootstrap/edge/variables.tf").read_text(encoding="utf-8") nginx = (ROOT / "bootstrap/edge/templates/default.conf.tftpl").read_text( encoding="utf-8" ) environment = (ROOT / "lib/jeannie/env.sh").read_text(encoding="utf-8") self.assertIn('nextpath_server_name = "nextpath.${var.server_name}"', main) self.assertIn("nextpath_backend_host", variables) self.assertIn("TF_VAR_nextpath_backend_host", environment) self.assertIn("server_name ${nextpath_server_name};", nginx) self.assertIn("proxy_pass http://${nextpath_backend_host}:${nextpath_backend_port}", nginx) self.assertIn("zone=nextpath_auth", nginx) self.assertIn("X-Forwarded-Proto https", nginx) if __name__ == "__main__": unittest.main()