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

test: move create_daily_schedule -> conftest to avoid repetition

parent df39d43e
No related branches found
No related tags found
1 merge request!52new program endpoint
......@@ -57,6 +57,27 @@ def assert_data(response, data) -> None:
assert response.data[key] == value
def create_daily_schedule(admin_api_client, daily_rrule, show) -> None:
"""creates a schedule for a show that repeats daily using the REST API."""
now = datetime.now()
in_one_hour = now + timedelta(hours=1)
in_seven_days = now + timedelta(days=7)
data = {
"schedule": {
"end_time": in_one_hour.strftime("%H:%M:%S"),
"first_date": now.strftime("%Y-%m-%d"),
"last_date": in_seven_days.strftime("%Y-%m-%d"),
"rrule_id": daily_rrule.id,
"show_id": show.id,
"start_time": now.strftime("%H:%M:%S"),
}
}
admin_api_client.post("/api/v1/schedules/", data=data, format="json")
@pytest.fixture
def profile() -> Profile:
return ProfileFactory()
......
from datetime import datetime, timedelta
import pytest
from conftest import create_daily_schedule
pytestmark = pytest.mark.django_db
......@@ -12,27 +12,6 @@ def url(include_virtual=False):
return "/api/v1/program/playout/"
def create_daily_schedule(admin_api_client, daily_rrule, show) -> None:
"""creates a schedule for a show that repeats daily using the REST API."""
now = datetime.now()
in_one_hour = now + timedelta(hours=1)
in_seven_days = now + timedelta(days=7)
data = {
"schedule": {
"end_time": in_one_hour.strftime("%H:%M:%S"),
"first_date": now.strftime("%Y-%m-%d"),
"last_date": in_seven_days.strftime("%Y-%m-%d"),
"rrule_id": daily_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 assert_entry(entry, show) -> None:
"""asserts the playout entry corresponds to the given show."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment