# 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(
            sorted(response.data, key=lambda t: t['start'])[0]['start'],
            '2015-02-01T08:00:00Z')

    @mock.patch('django.utils.timezone.now', mock_now)
    def test_transmission_before(self):
        response = self.client.get(
            '/api/2/transmissions',
            {'after': datetime.date(2015, 1, 14), 'before': datetime.date(2015, 1, 14)})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            sorted(response.data, key=lambda t: t['start'])[-1]['start'],
            '2015-01-14T14:00:00Z')

    @mock.patch('django.utils.timezone.now', mock_now)
    def test_transmission_now(self):
        response = self.client.get('/api/2/transmissions/now')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            (response.data['slug'], response.data['start']),
            ('classic-hits', '2015-01-06T14:00:00Z'))

    def test_transmissions_filter_calendar_nonexistend(self):
        response = self.client.get(
            '/api/2/transmissions', {'calendar': 9999})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)



# 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(
            sorted(response.data, key=lambda t: t['start'])[0]['start'],
            '2015-02-01T08:00:00Z')

    @mock.patch('django.utils.timezone.now', mock_now)
    def test_transmission_before(self):
        response = self.client.get(
            '/api/2/transmissions',
            {'after': datetime.date(2015, 1, 14), 'before': datetime.date(2015, 1, 14)})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            sorted(response.data, key=lambda t: t['start'])[-1]['start'],
            '2015-01-14T14:00:00Z')

    @mock.patch('django.utils.timezone.now', mock_now)
    def test_transmission_now(self):
        response = self.client.get('/api/2/transmissions/now')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            (response.data['slug'], response.data['start']),
            ('classic-hits', '2015-01-06T14:00:00Z'))

    def test_transmissions_filter_calendar_nonexistend(self):
        response = self.client.get(
            '/api/2/transmissions', {'calendar': 9999})
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)



class TestRestrictedMethodsScheduleAPI(TestDataMixin, APITestCase):