feat(api): load config using shared helpers

- add django settings module documentation
- use default for previously required fields

BREAKING CHANGE: The API command line interface require the
configuration file to be present. The default configuration file path is
`/etc/airtime/airtime.conf`
This commit is contained in:
jo 2022-03-01 13:22:24 +01:00 committed by Kyle Robbertze
parent 9af717ef7f
commit 2dcc654b70
12 changed files with 119 additions and 146 deletions

View file

@ -33,7 +33,7 @@ class TestIsSystemTokenOrUser(APITestCase):
self.assertFalse(allowed)
def test_token_correct(self):
token = settings.CONFIG.get("general", "api_key")
token = settings.CONFIG.general.api_key
request = APIRequestFactory().get(self.path)
request.user = AnonymousUser()
request.META["Authorization"] = f"Api-Key {token}"

View file

@ -14,7 +14,7 @@ class TestFileViewSet(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/files/{id}/download/"
cls.token = settings.CONFIG.get("general", "api_key")
cls.token = settings.CONFIG.general.api_key
def test_invalid(self):
path = self.path.format(id="a")
@ -49,7 +49,7 @@ class TestScheduleViewSet(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/schedule/"
cls.token = settings.CONFIG.get("general", "api_key")
cls.token = settings.CONFIG.general.api_key
def test_schedule_item_full_length(self):
music_dir = baker.make(