from __future__ import annotations import argparse import sys import unittest from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[3])) from deploy.tencent_tat import hyapp_admin_server_deploy as admin_deploy class AdminServerDeployScriptTests(unittest.TestCase): def test_remote_script_pulls_gitea_main_and_verifies_admin_health(self) -> None: args = argparse.Namespace( admin_bind_addr="172.16.0.6", admin_host="134.175.160.86", admin_port=13100, admin_user="", branch="main", dry_run=False, repo_url="git@gitea.haiyihy.com:hy/hyapp-server.git", source_dir="/opt/deploy/sources/hyapp-server", ssh_connect_timeout=15, transfer_timeout_seconds=300, ) script = admin_deploy.build_remote_script(args) self.assertIn("git fetch --prune origin \"$BRANCH\"", script) self.assertIn("git checkout -B \"$BRANCH\" \"origin/$BRANCH\"", script) self.assertIn("docker build -t \"$build_image\" -f server/admin/Dockerfile .", script) self.assertIn("timeout 300 scp", script) self.assertNotIn("rsync -az --partial", script) self.assertIn("systemctl restart hyapp-admin-server", script) self.assertIn("http://$ADMIN_BIND_ADDR:$ADMIN_PORT/healthz", script) self.assertIn("http://$ADMIN_BIND_ADDR:$ADMIN_PORT/readyz", script) if __name__ == "__main__": unittest.main()