feat(api): split api into multiple apps (#1626)
Fixes #1622 - split the api into 4 apps: core, history, schedule, storage - exploded the settings into testing/prod
This commit is contained in:
parent
87d2da9d84
commit
fce988aef1
120 changed files with 1499 additions and 1078 deletions
0
api/libretime_api/storage/tests/__init__.py
Normal file
0
api/libretime_api/storage/tests/__init__.py
Normal file
0
api/libretime_api/storage/tests/views/__init__.py
Normal file
0
api/libretime_api/storage/tests/views/__init__.py
Normal file
42
api/libretime_api/storage/tests/views/test_file.py
Normal file
42
api/libretime_api/storage/tests/views/test_file.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from model_bakery import baker
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from ...._fixtures import AUDIO_FILENAME, fixture_path
|
||||
|
||||
|
||||
class TestFileViewSet(APITestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.path = "/api/v2/files/{id}/download/"
|
||||
cls.token = settings.CONFIG.general.api_key
|
||||
|
||||
def test_invalid(self):
|
||||
path = self.path.format(id="a")
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Api-Key {self.token}")
|
||||
response = self.client.get(path)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
|
||||
def test_does_not_exist(self):
|
||||
path = self.path.format(id="1")
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Api-Key {self.token}")
|
||||
response = self.client.get(path)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_exists(self):
|
||||
music_dir = baker.make(
|
||||
"storage.MusicDir",
|
||||
directory=str(fixture_path),
|
||||
)
|
||||
f = baker.make(
|
||||
"storage.File",
|
||||
directory=music_dir,
|
||||
mime="audio/mp3",
|
||||
filepath=AUDIO_FILENAME,
|
||||
)
|
||||
path = self.path.format(id=str(f.pk))
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Api-Key {self.token}")
|
||||
response = self.client.get(path)
|
||||
self.assertEqual(response.status_code, 200)
|
Loading…
Add table
Add a link
Reference in a new issue