management/sounds_monitor: re-enable sounds scan

This commit is contained in:
Chris Tactic 2023-09-29 20:02:18 +02:00
parent 821995baaa
commit 7350426f16
3 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3
# TODO: SoundMonitor class
"""Monitor sound files; For each program, check for:
@ -60,10 +59,8 @@ class Command(BaseCommand):
)
def handle(self, *args, **options):
SoundMonitor()
monitor = SoundMonitor()
if options.get("scan"):
self.scan()
# if options.get('quality_check'):
# self.check_quality(check=(not options.get('scan')))
monitor.scan()
if options.get("monitor"):
self.monitor()
monitor.monitor()

View File

@ -0,0 +1,23 @@
import pytest
import os
from django.core.management import call_command
from django.conf import settings
wav = (
b"RIFF$\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x02\x00D\xac\x00\x00"
b"\x10\xb1\x02\x00\x04\x00\x10\x00data\x00\x00\x00\x00"
)
@pytest.mark.django_db
def test_adding_a_sound(programs, fs):
p0 = programs[0]
assert len(p0.sound_set.all()) == 0
s0 = os.path.join(
settings.PROJECT_ROOT, "static/media/%s/archives/sound.wav" % p0.path
)
fs.create_file(s0, contents=wav)
call_command("sounds_monitor", "-s")
assert len(p0.sound_set.all()) == 1

View File

@ -1,3 +1,4 @@
pytest~=7.2
pytest-django~=4.5
model_bakery~=1.10
pyfakefs~=5.2