#88 #89 : use pytest + reorganise settings (#92)

- !88 pytest on existing tests
- !89 reorganise settings (! see notes for deployment)

Co-authored-by: bkfox <thomas bkfox net>
Reviewed-on: rc/aircox#92
This commit is contained in:
Thomas Kairos
2023-03-28 14:40:49 +02:00
parent 4bebc56a28
commit 0e183099ed
31 changed files with 511 additions and 368 deletions

View File

@ -9,7 +9,7 @@ from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
from django.utils import timezone as tz
import aircox.settings as settings
from aircox.conf import settings
from aircox.models import Log
from aircox.models.log import LogArchiver
@ -29,9 +29,9 @@ class Command(BaseCommand):
"-a",
"--age",
type=int,
default=settings.AIRCOX_LOGS_ARCHIVES_AGE,
default=settings.LOGS_ARCHIVES_AGE,
help="minimal age in days of logs to archive. Default is "
"settings.AIRCOX_LOGS_ARCHIVES_AGE",
"settings.LOGS_ARCHIVES_AGE",
)
group.add_argument(
"-k",

View File

@ -2,9 +2,9 @@
sound.
Playlists are in CSV format, where columns are separated with a
'{settings.AIRCOX_IMPORT_PLAYLIST_CSV_DELIMITER}'. Text quote is
{settings.AIRCOX_IMPORT_PLAYLIST_CSV_TEXT_QUOTE}.
The order of the elements is: {settings.AIRCOX_IMPORT_PLAYLIST_CSV_COLS}
'{settings.IMPORT_PLAYLIST_CSV_DELIMITER}'. Text quote is
{settings.IMPORT_PLAYLIST_CSV_TEXT_QUOTE}.
The order of the elements is: {settings.IMPORT_PLAYLIST_CSV_COLS}
If 'minutes' or 'seconds' are given, position will be expressed as timed
position, instead of position in playlist.
@ -16,7 +16,7 @@ from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
from aircox import settings
from aircox.conf import settings
from aircox.models import Sound, Track
__doc__ = __doc__.format(settings=settings)
@ -61,9 +61,9 @@ class PlaylistImport:
)
and row.strip()
),
fieldnames=settings.AIRCOX_IMPORT_PLAYLIST_CSV_COLS,
delimiter=settings.AIRCOX_IMPORT_PLAYLIST_CSV_DELIMITER,
quotechar=settings.AIRCOX_IMPORT_PLAYLIST_CSV_TEXT_QUOTE,
fieldnames=settings.IMPORT_PLAYLIST_CSV_COLS,
delimiter=settings.IMPORT_PLAYLIST_CSV_DELIMITER,
quotechar=settings.IMPORT_PLAYLIST_CSV_TEXT_QUOTE,
)
)
@ -80,7 +80,7 @@ class PlaylistImport:
)
return
maps = settings.AIRCOX_IMPORT_PLAYLIST_CSV_COLS
maps = settings.IMPORT_PLAYLIST_CSV_COLS
tracks = []
logger.info("parse csv file " + self.path)

View File

@ -20,7 +20,7 @@ Where:
To check quality of files, call the command sound_quality_check using the
parameters given by the setting AIRCOX_SOUND_QUALITY. This script requires
parameters given by the setting SOUND_QUALITY. This script requires
Sox (and soxi).
"""
import atexit
@ -33,7 +33,7 @@ from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
from watchdog.observers import Observer
from aircox import settings
from aircox.conf import settings
from aircox.management.sound_file import SoundFile
from aircox.management.sound_monitor import MonitorHandler
from aircox.models import Program, Sound
@ -67,12 +67,12 @@ class Command(BaseCommand):
logger.info("#%d %s", program.id, program.title)
self.scan_for_program(
program,
settings.AIRCOX_SOUND_ARCHIVES_SUBDIR,
settings.SOUND_ARCHIVES_SUBDIR,
type=Sound.TYPE_ARCHIVE,
)
self.scan_for_program(
program,
settings.AIRCOX_SOUND_EXCERPTS_SUBDIR,
settings.SOUND_EXCERPTS_SUBDIR,
type=Sound.TYPE_EXCERPT,
)
dirs.append(os.path.join(program.abspath))
@ -91,7 +91,7 @@ class Command(BaseCommand):
# sounds in directory
for path in os.listdir(subdir):
path = os.path.join(subdir, path)
if not path.endswith(settings.AIRCOX_SOUND_FILE_EXT):
if not path.endswith(settings.SOUND_FILE_EXT):
continue
sound_file = SoundFile(path)
@ -115,12 +115,12 @@ class Command(BaseCommand):
"""Run in monitor mode."""
with futures.ThreadPoolExecutor() as pool:
archives_handler = MonitorHandler(
settings.AIRCOX_SOUND_ARCHIVES_SUBDIR,
settings.SOUND_ARCHIVES_SUBDIR,
pool,
type=Sound.TYPE_ARCHIVE,
)
excerpts_handler = MonitorHandler(
settings.AIRCOX_SOUND_EXCERPTS_SUBDIR,
settings.SOUND_EXCERPTS_SUBDIR,
pool,
type=Sound.TYPE_EXCERPT,
)
@ -128,12 +128,12 @@ class Command(BaseCommand):
observer = Observer()
observer.schedule(
archives_handler,
settings.AIRCOX_PROGRAMS_DIR_ABS,
settings.PROGRAMS_DIR_ABS,
recursive=True,
)
observer.schedule(
excerpts_handler,
settings.AIRCOX_PROGRAMS_DIR_ABS,
settings.PROGRAMS_DIR_ABS,
recursive=True,
)
observer.start()