import os import subprocess import sys import tempfile import time from pathlib import Path from unittest import TestCase from station.rpc import call class BackendTest(TestCase): def test_offline_rpc_task_lifecycle_and_shutdown(self): with tempfile.TemporaryDirectory() as folder: socket=Path(folder)/'backend.sock' proc=subprocess.Popen([sys.executable,'-m','station.control_service','--socket',str(socket),'--offline'], stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) try: deadline=time.monotonic()+10 while not socket.exists() and proc.poll() is None and time.monotonic()