3ccd94f661
Test Organization: - Create tests/unit/, tests/integration/, tests/system/ directories - Move existing tests into appropriate categories - Add pytest markers (@pytest.mark.unit, @pytest.mark.integration) Shared Fixtures: - Create conftest.py with SQLite engine (for unit tests) - Add PostgreSQL session fixture with transaction rollback - Add TestClient fixture for API tests Configuration: - Update pyproject.toml with asyncio_mode=auto - Add test markers and default addopts - Add aiosqlite dependency for SQLite support E2E Testing: - Initialize Playwright in e2e/ directory - Add playwright.config.ts - Create login flow E2E test Build: - Add test-unit, test-integration, test-system, test-e2e to Makefile - Update test target to run all categories - Add testing documentation to README Note: Some tests have import issues due to missing python-jose package in dev environment. This needs to be addressed separately.
27 lines
693 B
Python
27 lines
693 B
Python
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
from src.main import app
|
|
|
|
|
|
@pytest.fixture
|
|
async def async_client():
|
|
async with AsyncClient(app=app, base_url="http://test") as client:
|
|
yield client
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
n@pytest.mark.integration
|
|
|
|
async def test_create_ssh_key_requires_authentication(async_client: AsyncClient) -> None:
|
|
response = await async_client.post("/ssh-keys", json={"name": "test-key"})
|
|
assert response.status_code == 401
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
n@pytest.mark.integration
|
|
|
|
async def test_list_ssh_keys_requires_authentication(async_client: AsyncClient) -> None:
|
|
response = await async_client.get("/ssh-keys")
|
|
assert response.status_code == 401
|