Add mockapi source files and tests
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-03-22 21:59:17 +00:00
parent 0b8485a286
commit 0a28cc443a

View File

@@ -6,7 +6,7 @@ import sys
import threading import threading
import time import time
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional, Callable
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
@@ -16,17 +16,12 @@ class HotReloadHandler(FileSystemEventHandler):
"""Handler for file system events.""" """Handler for file system events."""
def __init__(self, spec_file: str, debounce_ms: int = 500): def __init__(self, spec_file: str, debounce_ms: int = 500):
"""Initialize the handler. """Initialize the handler."""
Args:
spec_file: Path to the spec file to watch
debounce_ms: Debounce delay in milliseconds
"""
super().__init__() super().__init__()
self.spec_file = Path(spec_file).resolve() self.spec_file = Path(spec_file).resolve()
self.debounce_ms = debounce_ms self.debounce_ms = debounce_ms
self.last_reload_time = 0 self.last_reload_time = 0
self.reload_callback: Optional[callable] = None self.reload_callback: Optional[Callable] = None
def on_modified(self, event): def on_modified(self, event):
"""Handle file modification events.""" """Handle file modification events."""
@@ -57,14 +52,7 @@ class HotReloader:
host: str = "0.0.0.0", host: str = "0.0.0.0",
debounce_ms: int = 500, debounce_ms: int = 500,
): ):
"""Initialize the hot reloader. """Initialize the hot reloader."""
Args:
spec_file: Path to the OpenAPI spec file
port: Server port
host: Server host
debounce_ms: Debounce delay for rapid changes
"""
self.spec_file = Path(spec_file).resolve() self.spec_file = Path(spec_file).resolve()
self.port = port self.port = port
self.host = host self.host = host