at 24.11-pre 1.7 kB view raw
1# This file contains type hints that can be prepended to Nix test scripts so they can be type 2# checked. 3 4from test_driver.driver import Driver 5from test_driver.vlan import VLan 6from test_driver.machine import Machine 7from test_driver.logger import AbstractLogger 8from typing import Callable, Iterator, ContextManager, Optional, List, Dict, Any, Union 9from typing_extensions import Protocol 10from pathlib import Path 11 12 13class RetryProtocol(Protocol): 14 def __call__(self, fn: Callable, timeout: int = 900) -> None: 15 raise Exception("This is just type information for the Nix test driver") 16 17 18class PollingConditionProtocol(Protocol): 19 def __call__( 20 self, 21 fun_: Optional[Callable] = None, 22 *, 23 seconds_interval: float = 2.0, 24 description: Optional[str] = None, 25 ) -> Union[Callable[[Callable], ContextManager], ContextManager]: 26 raise Exception("This is just type information for the Nix test driver") 27 28 29class CreateMachineProtocol(Protocol): 30 def __call__( 31 self, 32 start_command: str | dict, 33 *, 34 name: Optional[str] = None, 35 keep_vm_state: bool = False, 36 ) -> Machine: 37 raise Exception("This is just type information for the Nix test driver") 38 39 40start_all: Callable[[], None] 41subtest: Callable[[str], ContextManager[None]] 42retry: RetryProtocol 43test_script: Callable[[], None] 44machines: List[Machine] 45vlans: List[VLan] 46driver: Driver 47log: AbstractLogger 48create_machine: CreateMachineProtocol 49run_tests: Callable[[], None] 50join_all: Callable[[], None] 51serial_stdout_off: Callable[[], None] 52serial_stdout_on: Callable[[], None] 53polling_condition: PollingConditionProtocol