CI: build pipeline testet nun immer automatisch vor dem build alle Test. Ausserdem gibts einen deploy-pfad

This commit is contained in:
Rob committed 2026-10-07 20:44:51 +02:00
1 parent 971459c9bf
commit 2aad2c9d99
12 files changed
+543 -27

No files matched your search

+32 -2
View File
@@ -13,14 +13,18 @@ import server_lifecycle
@unittest.skipUnless(os.name == "nt", "Windows process management")
class ServerLifecycleTests(unittest.TestCase):
def simulate(self, process, listening=True, stop_error=False, confirm=True):
def simulate(self, process, listening=True, stop_error=False, confirm=True, frozen=False):
captured = {}
def capture(command, **kwargs):
captured.update(script=command[-1], env=kwargs["env"])
return subprocess.CompletedProcess(command, 0, "[]", "")
with patch.object(server_lifecycle.subprocess, "run", side_effect=capture):
root = Path(__file__).resolve().parents[2]
with patch.object(server_lifecycle.subprocess, "run", side_effect=capture), \
patch.object(server_lifecycle.sys, "frozen", frozen, create=True), \
patch.object(server_lifecycle.sys, "executable", str(root / "2_build" / "Tätigkeitsnachweis-Generator.exe")), \
patch.object(server_lifecycle, "__file__", str(root / "_MEI-test" / "server_lifecycle.py") if frozen else server_lifecycle.__file__):
server_lifecycle.stop_existing_server()
setup = r'''
@@ -140,6 +144,32 @@ function Confirm-ServerRestart {
self.assertNotIn("CONFIRM_CALLED", result.stderr)
self.assertNotIn("STOP_CALLED", result.stderr)
def test_exe_recognizes_sibling_development_server(self):
process = r'''[pscustomobject]@{
Name='python3.13.exe'; ExecutablePath='C:\Python\python3.13.exe';
CommandLine=('".venv\Scripts\python.exe" -m streamlit run "' +
(($env:APP_RESTART_PATHS | ConvertFrom-Json)[1]) +
'" --server.port=8501 --server.address=localhost')
}'''
for answer, expected_code in [(True, 0), (False, 2)]:
with self.subTest(confirm=answer):
result = self.simulate(process, frozen=True, confirm=answer)
self.assertEqual(result.returncode, expected_code, result.stderr)
self.assertIn("CONFIRM_CALLED", result.stderr)
if answer:
self.assertIn("STOP_CALLED", result.stderr)
else:
self.assertNotIn("STOP_CALLED", result.stderr)
def test_exe_preserves_unrelated_development_server(self):
result = self.simulate(r'''[pscustomobject]@{
Name='python3.13.exe'; ExecutablePath='C:\Python\python3.13.exe';
CommandLine='python -m streamlit run "C:\other-project\app.py"'
}''', frozen=True)
self.assertNotEqual(result.returncode, 0)
self.assertNotIn("CONFIRM_CALLED", result.stderr)
self.assertNotIn("STOP_CALLED", result.stderr)
def test_unrelated_server_is_preserved(self):
result = self.simulate(r'''[pscustomobject]@{
Name='python.exe'; CommandLine='streamlit run app.py';