# Path: radioco/apps/radioco/test_utils.py
# class TestDataMixin(object):
#     @classmethod
#     def setUpTestData(cls):
#         create_test_data()
#         cls.programme = Programme.objects.filter(name="Classic hits").get()
#         cls.schedule = cls.programme.schedule_set.first()
#         cls.calendar = cls.schedule.calendar
#         cls.episode = cls.programme.episode_set.first()
#         cls.another_calendar = Calendar.objects.create(name="Another")
# 
#         schedule, created = Schedule.objects.get_or_create(
#             programme=cls.programme,
#             calendar=cls.another_calendar,
#             type='S',
#             start_dt=pytz.utc.localize(datetime.datetime(2015, 1, 6, 16, 30, 0)))


import datetime
import mock
import pytz
from rest_framework import status
from rest_framework.test import APITestCase
from radioco.apps.radioco.test_utils import TestDataMixin
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 2)
        self.assertEqual(response.data[0]['title'], self.programme.name)

    def test_schedules_get_by_nonexisting_programme(self):
        response = self.client.get(
            '/api/2/schedules', {'programme': 'foo'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 0)

    def test_schedules_get_by_calendar(self):
        response = self.client.get(
            '/api/2/schedules', {'calendar': self.calendar.id})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 5)
        self.assertEqual(
            response.data[0]['calendar'], self.calendar.id)

    def test_schedules_get_by_nonexisting_calendar(self):
        response = self.client.get(
            '/api/2/schedules', {'calendar': '111'})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

    def test_schedules_get_by_type(self):
        response = self.client.get('/api/2/schedules?type=L')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 5)
        self.assertEqual(
            response.data[0]['calendar'], self.calendar.id)


# Path: radioco/apps/radioco/test_utils.py
# class TestDataMixin(object):
#     @classmethod
#     def setUpTestData(cls):
#         create_test_data()
#         cls.programme = Programme.objects.filter(name="Classic hits").get()
#         cls.schedule = cls.programme.schedule_set.first()
#         cls.calendar = cls.schedule.calendar
#         cls.episode = cls.programme.episode_set.first()
#         cls.another_calendar = Calendar.objects.create(name="Another")
# 
#         schedule, created = Schedule.objects.get_or_create(
#             programme=cls.programme,
#             calendar=cls.another_calendar,
#             type='S',
#             start_dt=pytz.utc.localize(datetime.datetime(2015, 1, 6, 16, 30, 0)))


# Path: radioco/apps/api/tests/test_schedules.py
import datetime
import mock
import pytz
from rest_framework import status
from rest_framework.test import APITestCase
from radioco.apps.radioco.test_utils import TestDataMixin

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 2)
        self.assertEqual(response.data[0]['title'], self.programme.name)

    def test_schedules_get_by_nonexisting_programme(self):
        response = self.client.get(
            '/api/2/schedules', {'programme': 'foo'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 0)

    def test_schedules_get_by_calendar(self):
        response = self.client.get(
            '/api/2/schedules', {'calendar': self.calendar.id})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 5)
        self.assertEqual(
            response.data[0]['calendar'], self.calendar.id)

    def test_schedules_get_by_nonexisting_calendar(self):
        response = self.client.get(
            '/api/2/schedules', {'calendar': '111'})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

    def test_schedules_get_by_type(self):
        response = self.client.get('/api/2/schedules?type=L')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 5)
        self.assertEqual(
            response.data[0]['calendar'], self.calendar.id)


    def test_schedules_get_by_nonexiting_type(self):