Skip to content
Snippets Groups Projects
Verified Commit 1ad92428 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

test: remove program tests

parent 09b50b26
No related branches found
No related tags found
1 merge request!52new program endpoint
from datetime import datetime, timedelta
import pytest
pytestmark = pytest.mark.django_db
def url(include_virtual=False):
year, month, day = datetime.today().year, datetime.today().month, datetime.today().day
if include_virtual:
return f"/api/v1/program/{year}/{month}/{day}/?include_virtual=true"
else:
return f"/api/v1/program/{year}/{month}/{day}/"
def create_once_schedule(admin_api_client, once_rrule, show) -> None:
"""creates a schedule for a show that repeats once using the REST API."""
now = datetime.now()
in_an_hour = now + timedelta(hours=1)
data = {
"schedule": {
"end_time": in_an_hour.strftime("%H:%M:%S"),
"first_date": now.strftime("%Y-%m-%d"),
"last_date": None,
"rrule_id": once_rrule.id,
"show_id": show.id,
"start_time": now.strftime("%H:%M:%S"),
},
}
admin_api_client.post("/api/v1/schedules/", data=data, format="json")
def test_day_schedule(admin_api_client, api_client, once_rrule, show):
create_once_schedule(admin_api_client, once_rrule, show)
response = api_client.get(url())
assert response.status_code == 200
assert len(response.json()) == 1
entry = response.json()[0]
assert not entry["timeslot"]["isVirtual"]
assert entry["show"]["id"] == show.id
assert entry["show"]["name"] == show.name
def test_day_schedule_include_virtual(
admin_api_client,
api_client,
once_rrule,
show,
fallback_show,
radio_settings,
):
create_once_schedule(admin_api_client, once_rrule, show)
response = api_client.get(url(include_virtual=True))
assert response.status_code == 200
assert len(response.json()) == 3
for entry in response.json():
if entry["timeslot"]["isVirtual"]:
assert entry["show"]["id"] == fallback_show.id
assert entry["show"]["name"] == fallback_show.name
else:
assert entry["show"]["id"] == show.id
assert entry["show"]["name"] == show.name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment