Add mockapi source files and tests
This commit is contained in:
@@ -6,7 +6,7 @@ import sys
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Optional, Callable
|
||||
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
@@ -16,17 +16,12 @@ class HotReloadHandler(FileSystemEventHandler):
|
||||
"""Handler for file system events."""
|
||||
|
||||
def __init__(self, spec_file: str, debounce_ms: int = 500):
|
||||
"""Initialize the handler.
|
||||
|
||||
Args:
|
||||
spec_file: Path to the spec file to watch
|
||||
debounce_ms: Debounce delay in milliseconds
|
||||
"""
|
||||
"""Initialize the handler."""
|
||||
super().__init__()
|
||||
self.spec_file = Path(spec_file).resolve()
|
||||
self.debounce_ms = debounce_ms
|
||||
self.last_reload_time = 0
|
||||
self.reload_callback: Optional[callable] = None
|
||||
self.reload_callback: Optional[Callable] = None
|
||||
|
||||
def on_modified(self, event):
|
||||
"""Handle file modification events."""
|
||||
@@ -57,14 +52,7 @@ class HotReloader:
|
||||
host: str = "0.0.0.0",
|
||||
debounce_ms: int = 500,
|
||||
):
|
||||
"""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
|
||||
"""
|
||||
"""Initialize the hot reloader."""
|
||||
self.spec_file = Path(spec_file).resolve()
|
||||
self.port = port
|
||||
self.host = host
|
||||
@@ -134,4 +122,4 @@ class HotReloader:
|
||||
self.server_process.terminate()
|
||||
self.server_process.wait()
|
||||
|
||||
self._start_server()
|
||||
self._start_server()
|
||||
|
||||
Reference in New Issue
Block a user