Merge dev to main: Security improvements and comprehensive test infrastructure #39
@@ -143,10 +143,20 @@ def mock_httpx_client():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_app(mock_config, temp_auth_file, temp_rbac_file, mock_docker_client):
|
||||
def test_app(mock_config, temp_auth_file, temp_rbac_file, mock_docker_client, tmp_path):
|
||||
"""Create FastAPI test client with mocked dependencies."""
|
||||
# Patch Docker client before importing main
|
||||
with patch("docker.DockerClient", return_value=mock_docker_client):
|
||||
# Create dummy static directory for tests
|
||||
static_dir = tmp_path / "static"
|
||||
static_dir.mkdir()
|
||||
(static_dir / "index.html").write_text("<html><body>Test</body></html>")
|
||||
|
||||
# Patch Docker client and static directory before importing main
|
||||
with patch("docker.DockerClient", return_value=mock_docker_client), \
|
||||
patch("main.StaticFiles") as mock_static:
|
||||
# Make StaticFiles work with our test directory
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
mock_static.return_value = StaticFiles(directory=str(static_dir), html=True)
|
||||
|
||||
from main import app
|
||||
client = TestClient(app)
|
||||
yield client
|
||||
|
||||
Reference in New Issue
Block a user