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