fix tests
This commit is contained in:
@ -133,8 +133,10 @@ class Monitor:
|
||||
# get sound
|
||||
diff = None
|
||||
sound = Sound.objects.path(air_uri).first()
|
||||
if sound and sound.episode_id is not None:
|
||||
diff = Diffusion.objects.episode(id=sound.episode_id).on_air().now(air_time).first()
|
||||
if sound:
|
||||
ids = sound.episodesound_set.values_list("episode_id", flat=True)
|
||||
if ids:
|
||||
diff = Diffusion.objects.filter(episode_id__in=ids).on_air().now(air_time).first()
|
||||
|
||||
# log sound on air
|
||||
return self.log(
|
||||
|
@ -146,24 +146,28 @@ def episode(program):
|
||||
def sound(program, episode):
|
||||
sound = models.Sound(
|
||||
program=program,
|
||||
episode=episode,
|
||||
name="sound",
|
||||
type=models.Sound.TYPE_ARCHIVE,
|
||||
position=0,
|
||||
broadcast=True,
|
||||
file="sound.mp3",
|
||||
)
|
||||
sound.save(check=False)
|
||||
sound.save(sync=False)
|
||||
return sound
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def episode_sound(episode, sound):
|
||||
obj = models.EpisodeSound(episode=episode, sound=sound, position=0, broadcast=sound.broadcast)
|
||||
obj.save()
|
||||
return obj
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sounds(program):
|
||||
items = [
|
||||
models.Sound(
|
||||
name=f"sound {i}",
|
||||
program=program,
|
||||
type=models.Sound.TYPE_ARCHIVE,
|
||||
position=i,
|
||||
broadcast=True,
|
||||
file=f"sound-{i}.mp3",
|
||||
)
|
||||
for i in range(0, 3)
|
||||
|
@ -20,7 +20,7 @@ def monitor(streamer):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def diffusion(program, episode, sound):
|
||||
def diffusion(program, episode, episode_sound):
|
||||
return baker.make(
|
||||
models.Diffusion,
|
||||
program=program,
|
||||
@ -33,10 +33,10 @@ def diffusion(program, episode, sound):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def source(monitor, streamer, sound, diffusion):
|
||||
def source(monitor, streamer, episode_sound, diffusion):
|
||||
source = next(monitor.streamer.playlists)
|
||||
source.uri = sound.file.path
|
||||
source.episode_id = sound.episode_id
|
||||
source.uri = episode_sound.sound.file.path
|
||||
source.episode_id = episode_sound.episode_id
|
||||
source.air_time = diffusion.start + tz.timedelta(seconds=10)
|
||||
return source
|
||||
|
||||
@ -185,7 +185,7 @@ class TestMonitor:
|
||||
monitor.trace_tracks(log)
|
||||
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_handle_diffusions(self, monitor, streamer, diffusion, sound):
|
||||
def test_handle_diffusions(self, monitor, streamer, diffusion, episode_sound):
|
||||
interface(
|
||||
monitor,
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ class TestPlaylistSource:
|
||||
@pytest.mark.django_db
|
||||
def test_get_sound_queryset(self, playlist_source, sounds):
|
||||
query = playlist_source.get_sound_queryset()
|
||||
assert all(r.program_id == playlist_source.program.pk and r.type == r.TYPE_ARCHIVE for r in query)
|
||||
assert all(r.program_id == playlist_source.program.pk and r.broadcast for r in query)
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_get_playlist(self, playlist_source, sounds):
|
||||
|
Reference in New Issue
Block a user