forked from rc/aircox
Feat: packaging (#127)
- Add configuration files for packaging - Precommit now uses ruff Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#127
This commit is contained in:
@ -12,11 +12,7 @@ class TestEpisode:
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_podcasts(self, episode, podcasts):
|
||||
podcasts = {
|
||||
podcast.pk: podcast
|
||||
for podcast in podcasts
|
||||
if podcast.episode == episode
|
||||
}
|
||||
podcasts = {podcast.pk: podcast for podcast in podcasts if podcast.episode == episode}
|
||||
for data in episode.podcasts:
|
||||
podcast = podcasts[data["pk"]]
|
||||
assert data["name"] == podcast.name
|
||||
|
@ -12,44 +12,28 @@ class TestRerunQuerySet:
|
||||
@pytest.mark.django_db
|
||||
def test_station_by_obj(self, stations, schedules):
|
||||
for station in stations:
|
||||
queryset = (
|
||||
Schedule.objects.station(station)
|
||||
.distinct()
|
||||
.values_list("program__station", flat=True)
|
||||
)
|
||||
queryset = Schedule.objects.station(station).distinct().values_list("program__station", flat=True)
|
||||
assert queryset.count() == 1
|
||||
assert queryset.first() == station.pk
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_station_by_id(self, stations, schedules):
|
||||
for station in stations:
|
||||
queryset = (
|
||||
Schedule.objects.station(id=station.pk)
|
||||
.distinct()
|
||||
.values_list("program__station", flat=True)
|
||||
)
|
||||
queryset = Schedule.objects.station(id=station.pk).distinct().values_list("program__station", flat=True)
|
||||
assert queryset.count() == 1
|
||||
assert queryset.first() == station.pk
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_program_by_obj(self, programs, schedules):
|
||||
for program in programs:
|
||||
queryset = (
|
||||
Schedule.objects.program(program)
|
||||
.distinct()
|
||||
.values_list("program", flat=True)
|
||||
)
|
||||
queryset = Schedule.objects.program(program).distinct().values_list("program", flat=True)
|
||||
assert queryset.count() == 1
|
||||
assert queryset.first() == program.pk
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_program_by_id(self, programs, schedules):
|
||||
for program in programs:
|
||||
queryset = (
|
||||
Schedule.objects.program(id=program.pk)
|
||||
.distinct()
|
||||
.values_list("program", flat=True)
|
||||
)
|
||||
queryset = Schedule.objects.program(id=program.pk).distinct().values_list("program", flat=True)
|
||||
assert queryset.count() == 1
|
||||
assert queryset.first() == program.pk
|
||||
|
||||
@ -60,11 +44,7 @@ class TestRerunQuerySet:
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_initial(self, schedules):
|
||||
queryset = (
|
||||
Schedule.objects.initial()
|
||||
.distinct()
|
||||
.values_list("initial", flat=True)
|
||||
)
|
||||
queryset = Schedule.objects.initial().distinct().values_list("initial", flat=True)
|
||||
assert queryset.count() == 1
|
||||
assert queryset.first() is None
|
||||
|
||||
|
@ -49,9 +49,7 @@ class TestSchedule:
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_dates_of_month_ponctual(self):
|
||||
schedule = baker.prepare(
|
||||
Schedule, frequency=Schedule.Frequency.ponctual
|
||||
)
|
||||
schedule = baker.prepare(Schedule, frequency=Schedule.Frequency.ponctual)
|
||||
at = schedule.date + relativedelta(months=4)
|
||||
assert schedule.dates_of_month(at) == []
|
||||
|
||||
@ -59,9 +57,7 @@ class TestSchedule:
|
||||
@pytest.mark.parametrize("months", range(0, 25, 4))
|
||||
@pytest.mark.parametrize("hour", range(0, 24, 4))
|
||||
def test_dates_of_month_last(self, months, hour):
|
||||
schedule = baker.prepare(
|
||||
Schedule, time=time(hour, 00), frequency=Schedule.Frequency.last
|
||||
)
|
||||
schedule = baker.prepare(Schedule, time=time(hour, 00), frequency=Schedule.Frequency.last)
|
||||
at = schedule.date + relativedelta(months=months)
|
||||
datetimes = schedule.dates_of_month(at)
|
||||
assert len(datetimes) == 1
|
||||
@ -73,9 +69,7 @@ class TestSchedule:
|
||||
at = date(at.year, at.month, month_info[1])
|
||||
if at.weekday() < schedule.date.weekday():
|
||||
at -= timedelta(days=7)
|
||||
at += timedelta(days=schedule.date.weekday()) - timedelta(
|
||||
days=at.weekday()
|
||||
)
|
||||
at += timedelta(days=schedule.date.weekday()) - timedelta(days=at.weekday())
|
||||
assert dt.date() == at
|
||||
|
||||
# since the same method is used for first, second, etc. frequencies
|
||||
@ -84,9 +78,7 @@ class TestSchedule:
|
||||
@pytest.mark.parametrize("months", range(0, 25, 4))
|
||||
@pytest.mark.parametrize("hour", range(0, 24, 4))
|
||||
def test_dates_of_month_every(self, months, hour):
|
||||
schedule = baker.prepare(
|
||||
Schedule, time=time(hour, 00), frequency=Schedule.Frequency.every
|
||||
)
|
||||
schedule = baker.prepare(Schedule, time=time(hour, 00), frequency=Schedule.Frequency.every)
|
||||
at = schedule.date + relativedelta(months=months)
|
||||
datetimes = schedule.dates_of_month(at)
|
||||
last = None
|
||||
@ -128,8 +120,4 @@ class TestSchedule:
|
||||
episodes, diffusions = schedule.diffusions_of_month(at)
|
||||
|
||||
assert all(r.date in dates for r in episodes)
|
||||
assert all(
|
||||
(not r.initial or r.date in dates)
|
||||
and r.type == Diffusion.TYPE_ON_AIR
|
||||
for r in diffusions
|
||||
)
|
||||
assert all((not r.initial or r.date in dates) and r.type == Diffusion.TYPE_ON_AIR for r in diffusions)
|
||||
|
@ -39,8 +39,7 @@ def test_user_default_groups():
|
||||
groups = Group.objects.filter(name__in=default_groups.keys())
|
||||
assert groups.exists()
|
||||
assert all(
|
||||
set(group.permissions.all().values_list("codename", flat=True))
|
||||
== set(default_groups[group.name])
|
||||
set(group.permissions.all().values_list("codename", flat=True)) == set(default_groups[group.name])
|
||||
for group in groups
|
||||
)
|
||||
user_groups = set(user.groups.all().values_list("name", flat=True))
|
||||
@ -104,7 +103,5 @@ def test_schedule_pre_delete(sched, eps_diffs):
|
||||
@pytest.mark.django_db
|
||||
def test_diffusion_post_delete(eps_diffs):
|
||||
eps = eps_diffs[0][0]
|
||||
Diffusion.objects.filter(
|
||||
id__in=[r.id for r in eps.diffusion_set.all()]
|
||||
).delete()
|
||||
Diffusion.objects.filter(id__in=[r.id for r in eps.diffusion_set.all()]).delete()
|
||||
assert Episode.objects.filter(id=eps.id).first() is None
|
||||
|
Reference in New Issue
Block a user