Replace the FastAPI/SQLAlchemy/Alembic web service with a Django project
laid out like cumorah-build: manage.py at the root, settings in the
privatestudio.settings package (base/dev/production), and a
privatestudio.studio app.
- Studio model owns a unique bucket_name; access is granted through
membership in the studio's auth Group. Assets, profiles and jobs are
scoped to a studio; API keys and S3 credentials stay per user.
- JSON API via Django Ninja under /api/ (profiles and transcode jobs now
live under /api/studios/{bucket}/).
- S3-compatible interface as plain class-based views under /s3/,
supporting bearer tokens and AWS v4 signatures.
- create_studio and create_key management commands replace ps-serve.
- Fresh Django initial migration; tests ported to Django TestCase.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import shutil
|
|
import tempfile
|
|
|
|
from django.contrib.auth.models import Group, User
|
|
from django.test import TestCase, override_settings
|
|
|
|
from privatestudio.studio.auth import create_api_key
|
|
from privatestudio.studio.models import Studio
|
|
|
|
|
|
class StudioTestCase(TestCase):
|
|
"""Creates a user in a group that grants access to the 'demo' studio, plus an API key."""
|
|
|
|
def setUp(self):
|
|
self.storage_dir = tempfile.mkdtemp()
|
|
self.addCleanup(shutil.rmtree, self.storage_dir, ignore_errors=True)
|
|
settings_override = override_settings(PRIVATESTUDIO_STORAGE_PATH=self.storage_dir)
|
|
settings_override.enable()
|
|
self.addCleanup(settings_override.disable)
|
|
|
|
self.group = Group.objects.create(name="demo-team")
|
|
self.studio = Studio.objects.create(name="Demo", bucket_name="demo", group=self.group)
|
|
self.user = User.objects.create_user("testuser")
|
|
self.user.groups.add(self.group)
|
|
self.key, _ = create_api_key(self.user)
|
|
|
|
def auth(self, key=None):
|
|
return {"Authorization": f"Bearer {key or self.key}"}
|