import ast import hashlib import importlib.util import json from pathlib import Path from tempfile import TemporaryDirectory from unittest.mock import patch import unittest ROOT=Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('release_preflight_test',ROOT/'release_preflight.py') preflight=importlib.util.module_from_spec(spec);spec.loader.exec_module(preflight) class ReleasePreflightTest(unittest.TestCase): def test_preflight_never_restarts_existing_services(self): for name,args,cwd,timeout in preflight.command_list('e3a08f9e-af12-4695-99bd-8b51c0520021'): self.assertNotIn('up',args);self.assertNotIn('restart',args);self.assertNotIn('--with-bridges',args) self.assertGreater(timeout,0) first=preflight.command_list('e3a08f9e-af12-4695-99bd-8b51c0520021')[0][1] self.assertIn('--test-only',first) def test_php_runs_without_network_or_writeable_root(self): args=next(args for name,args,cwd,timeout in preflight.command_list('p') if name=='php83_offline') self.assertIn('--read-only',args);self.assertEqual(args[args.index('--network')+1],'none') self.assertEqual(args[args.index('--user')+1],'1000:1000') def test_native_bundle_requires_same_development_source(self): with TemporaryDirectory() as d: root=Path(d)/'root';repo=Path(d)/'repo';out=root/'acceptance/php-src' out.mkdir(parents=True);repo.mkdir() source=b'