#132 | #121: backoffice / dev-1.0-121 (#131)

cfr #121

Co-authored-by: Christophe Siraut <d@tobald.eu.org>
Co-authored-by: bkfox <thomas bkfox net>
Co-authored-by: Thomas Kairos <thomas@bkfox.net>
Reviewed-on: rc/aircox#131
Co-authored-by: Chris Tactic <ctactic@noreply.git.radiocampus.be>
Co-committed-by: Chris Tactic <ctactic@noreply.git.radiocampus.be>
This commit is contained in:
2024-04-28 22:02:09 +02:00
committed by Thomas Kairos
parent 1e17a1334a
commit 55123c386d
348 changed files with 124397 additions and 17879 deletions

View File

@ -1,6 +1,7 @@
from datetime import time, timedelta
import itertools
import logging
import os
from django.conf import settings
from django.contrib.auth.models import User
@ -130,25 +131,32 @@ def episode(episodes):
@pytest.fixture
def podcasts(episodes):
items = []
for episode in episodes:
sounds = baker.prepare(
models.Sound,
episode=episode,
program=episode.program,
is_public=True,
_quantity=2,
)
for i, sound in enumerate(sounds):
sound.file = f"test_sound_{episode.pk}_{i}.mp3"
items += sounds
return items
def sound(program):
return baker.make(models.Sound, file="tmp/test.wav", program=program)
@pytest.fixture
def sound(program):
return baker.make(models.Sound, file="tmp/test.wav", program=program)
def sounds(program):
objs = [
models.Sound(program=program, file=f"tmp/test-{i}.wav", broadcast=(i == 0), is_downloadable=(i == 1))
for i in range(0, 3)
]
models.Sound.objects.bulk_create(objs)
return objs
@pytest.fixture
def podcasts(episode, sounds):
objs = [
models.EpisodeSound(
episode=episode,
sound=sound,
broadcast=True,
)
for sound in sounds
]
models.EpisodeSound.objects.bulk_create(objs)
return objs
@pytest.fixture
@ -157,3 +165,15 @@ def tracks(episode, sound):
items += [baker.prepare(models.Track, sound=sound, position=i, timestamp=i * 60) for i in range(0, 3)]
models.Track.objects.bulk_create(items)
return items
@pytest.fixture
def user():
return User.objects.create_user(username="user1", password="bar")
@pytest.fixture
def png_content():
image_file = "{}/image.png".format(os.path.dirname(__file__))
with open(image_file, "rb") as fh:
return fh.read()