Files
rehearshalhub/api/tests/integration/test_api_bands.py
Steffen Schuhmann f7be1b994d Initial commit: RehearsalHub POC
Full-stack self-hosted band rehearsal platform:

Backend (FastAPI + SQLAlchemy 2.0 async):
- Auth with JWT (register, login, /me, settings)
- Band management with Nextcloud folder integration
- Song management with audio version tracking
- Nextcloud scan to auto-import audio files
- Band membership with link-based invite system
- Song comments
- Audio analysis worker (BPM, key, loudness, waveform)
- Nextcloud activity watcher for auto-import
- WebSocket support for real-time annotation updates
- Alembic migrations (0001–0003)
- Repository pattern, Ruff + mypy configured

Frontend (React 18 + Vite + TypeScript strict):
- Login/register page with post-login redirect
- Home page with band list and creation form
- Band page with member panel, invite link, song list, NC scan
- Song page with waveform player, annotations, comment thread
- Settings page for per-user Nextcloud credentials
- Invite acceptance page (/invite/:token)
- ESLint v9 flat config + TypeScript strict mode

Infrastructure:
- Docker Compose: PostgreSQL, Redis, API, worker, watcher, nginx
- nginx reverse proxy for static files + /api/ proxy
- make check runs all linters before docker compose build

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 21:53:03 +01:00

75 lines
2.5 KiB
Python

"""Integration tests for band endpoints."""
import uuid
import pytest
from tests.factories import create_band, create_member
@pytest.mark.asyncio
@pytest.mark.integration
async def test_create_band(client, db_session, auth_headers_for, current_member):
headers = await auth_headers_for(current_member)
resp = await client.post(
"/api/v1/bands",
json={"name": "My Band", "slug": "my-band-001", "genre_tags": ["rock"]},
headers=headers,
)
assert resp.status_code == 201, resp.text
data = resp.json()
assert data["name"] == "My Band"
assert data["slug"] == "my-band-001"
assert data["genre_tags"] == ["rock"]
@pytest.mark.asyncio
@pytest.mark.integration
async def test_create_band_duplicate_slug_returns_409(client, db_session, auth_headers_for, current_member):
headers = await auth_headers_for(current_member)
await create_band(db_session, name="Existing", slug="taken-slug", creator_id=current_member.id)
await db_session.commit()
resp = await client.post(
"/api/v1/bands",
json={"name": "Another", "slug": "taken-slug"},
headers=headers,
)
assert resp.status_code == 409
@pytest.mark.asyncio
@pytest.mark.integration
async def test_get_band_with_members(client, db_session, auth_headers_for, current_member):
headers = await auth_headers_for(current_member)
band = await create_band(db_session, creator_id=current_member.id)
await db_session.commit()
resp = await client.get(f"/api/v1/bands/{band.id}", headers=headers)
assert resp.status_code == 200, resp.text
data = resp.json()
assert data["id"] == str(band.id)
assert len(data["memberships"]) == 1
assert data["memberships"][0]["role"] == "admin"
@pytest.mark.asyncio
@pytest.mark.integration
async def test_get_band_non_member_returns_403(client, db_session, auth_headers_for, current_member):
headers = await auth_headers_for(current_member)
# Band with a different creator
other_member = await create_member(db_session, email="other@test.com")
band = await create_band(db_session, creator_id=other_member.id)
await db_session.commit()
resp = await client.get(f"/api/v1/bands/{band.id}", headers=headers)
assert resp.status_code == 403
@pytest.mark.asyncio
@pytest.mark.integration
async def test_get_band_not_found_returns_404(client, db_session, auth_headers_for, current_member):
headers = await auth_headers_for(current_member)
resp = await client.get(f"/api/v1/bands/{uuid.uuid4()}", headers=headers)
assert resp.status_code in (403, 404)