!112 !94: tests commons modules that contains most of the logic + zoneinfo (#113)

!112

Co-authored-by: bkfox <thomas bkfox net>
Reviewed-on: rc/aircox#113
This commit is contained in:
Thomas Kairos
2023-08-23 15:28:17 +02:00
parent f9ad81ddac
commit 2ce435fb5d
22 changed files with 253 additions and 108 deletions

View File

@ -2,6 +2,10 @@ from datetime import time, timedelta
import itertools
import logging
from django.conf import settings
from django.contrib.auth.models import User
from django.test import RequestFactory
import pytest
from model_bakery import baker
@ -9,6 +13,21 @@ from aircox import models
from aircox.test import Interface
req_factory = RequestFactory()
"""Request Factory used among different tests."""
settings.ALLOWED_HOSTS = list(settings.ALLOWED_HOSTS) + [
"sub.server.org",
"server.org",
]
@pytest.fixture
def staff_user():
return baker.make(User, is_active=True, is_staff=True)
@pytest.fixture
def logger():
logger = Interface(
@ -18,8 +37,24 @@ def logger():
@pytest.fixture
def stations():
return baker.make(models.Station, _quantity=2)
def station():
return baker.make(
models.Station,
hosts="server.org",
audio_streams="stream 1\nstream 2",
default=True,
)
@pytest.fixture
def sub_station():
"""Non-default station."""
return baker.make(models.Station, hosts="sub.server.org", default=False)
@pytest.fixture
def stations(station, sub_station):
return [station, sub_station]
@pytest.fixture
@ -28,7 +63,11 @@ def programs(stations):
itertools.chain(
*(
baker.make(
models.Program, station=station, cover=None, _quantity=2
models.Program,
station=station,
cover=None,
status=models.Program.STATUS_PUBLISHED,
_quantity=2,
)
for station in stations
)