# Path: radioco/apps/api/serializers.py
# class AbsoluteURLField(serializers.URLField):
# class DateTimeFieldTz(serializers.DateTimeField):
# class ProgrammeSerializer(serializers.ModelSerializer):
#     class Meta:
# class RadiocomProgrammeSerializer(serializers.ModelSerializer):
#     class Meta:
# class EpisodeSerializer(serializers.ModelSerializer):
#     class Meta:
# class ScheduleSerializer(serializers.ModelSerializer):
#     class Meta:
# class TransmissionSerializer(serializers.Serializer):
# class RadiocomTransmissionSerializer(serializers.Serializer):
# class TransmissionSerializerLight(serializers.Serializer):  # WARNING: Hack to save changes
# class RadiocomConfigurationSerializer(serializers.ModelSerializer):
#     class Meta:
#     def __init__(self, method_name=None, source=None, reverse_url=None, **kwargs):
#     def to_representation(self, value):
#     def to_representation(self, date):
#     def get_title(self, schedule):
#     def validate(self, attrs):
#     def validate(self, attrs):
#     def get_station_photos(self, obj):
#     def get_facebook_url(self, obj):
#     def get_twitter_url(self, obj):
# 
# 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/schedules/models.py
# class Transmission(object):
#     """
#     Temporal object generated according to recurrence rules or schedule information
#     It contains concrete dates
#     """
#     def __init__(self, schedule, date, episode=None):
#         self.schedule = schedule
#         self.programme = schedule.programme
#         self.start = date
#         self.episode = episode
# 
#     @property
#     def name(self):
#         return self.programme.name
# 
#     @property
#     def slug(self):
#         return self.programme.slug
# 
#     @property
#     def end(self):
#         return self.start + self.programme.runtime
# 
#     @property
#     def programme_url(self):
#         return reverse('programmes:detail', args=[self.programme.slug])
# 
#     @property
#     def episode_url(self):
#         if not self.episode:
#             return None
#         return reverse(
#             'programmes:episode_detail',
#             args=(self.slug, self.episode.season, self.episode.number_in_season)
#         )
# 
#     @classmethod
#     def at(cls, at):
#         schedules = Schedule.objects.filter(
#             calendar__is_active=True, effective_start_dt__lte=at
#         ).filter(
#             Q(effective_end_dt__gt=at) |
#             Q(effective_end_dt__isnull=True)
#         ).select_related('programme')
#         for schedule in schedules:
#             date = schedule.date_before(at)
#             if date and date <= at < date + schedule.runtime:
#                 # Get episode
#                 try:
#                     episode = Episode.objects.get(issue_date=date)
#                 except Episode.DoesNotExist:
#                     episode = None
#                 # yield transmission
#                 yield cls(schedule, date, episode)
# 
#     @classmethod
#     def between(cls, after, before, schedules=None):
#         """
#         Return a tuple of Schedule and Transmissions sorted by date
#         """
#         if schedules is None:
#             schedules = Schedule.objects.filter(calendar__is_active=True)
# 
#         schedules = schedules.filter(
#             effective_start_dt__lt=before
#         ).filter(
#             Q(effective_end_dt__gt=after) |
#             Q(effective_end_dt__isnull=True)
#         ).select_related('programme')
# 
#         # Querying episodes episodes in that period of time
#         episodes = Episode.objects.filter(
#             issue_date__lt=before, issue_date__gte=after
#         )
#         episodes = {_episode.issue_date: _episode for _episode in episodes}
# 
#         transmission_dates = [
#             map(partial(_return_tuple, item2=schedule), schedule.dates_between(after, before))
#             for schedule in schedules
#         ]
#         sorted_transmission_dates = heapq.merge(*transmission_dates)
#         for sorted_transmission_date, schedule in sorted_transmission_dates:
#             # Adding episodes matching by date, we don't care about if this info is not correct
#             yield cls(schedule, sorted_transmission_date, episodes.get(sorted_transmission_date))


import datetime
import pytz
from django.test import TestCase, RequestFactory
from rest_framework import status
from radioco.apps.api import serializers
from radioco.apps.radioco.test_utils import TestDataMixin
from radioco.apps.schedules.models import Transmission




MOCK_CONTEXT = {'request': RequestFactory().get('')}


class TestApi(TestDataMixin):

    def test_api(self):
        response = self.client.get('/api/2/')
        self.assertEqual(response.status_code, status.HTTP_200_OK)



# Path: radioco/apps/api/serializers.py
# class AbsoluteURLField(serializers.URLField):
# class DateTimeFieldTz(serializers.DateTimeField):
# class ProgrammeSerializer(serializers.ModelSerializer):
#     class Meta:
# class RadiocomProgrammeSerializer(serializers.ModelSerializer):
#     class Meta:
# class EpisodeSerializer(serializers.ModelSerializer):
#     class Meta:
# class ScheduleSerializer(serializers.ModelSerializer):
#     class Meta:
# class TransmissionSerializer(serializers.Serializer):
# class RadiocomTransmissionSerializer(serializers.Serializer):
# class TransmissionSerializerLight(serializers.Serializer):  # WARNING: Hack to save changes
# class RadiocomConfigurationSerializer(serializers.ModelSerializer):
#     class Meta:
#     def __init__(self, method_name=None, source=None, reverse_url=None, **kwargs):
#     def to_representation(self, value):
#     def to_representation(self, date):
#     def get_title(self, schedule):
#     def validate(self, attrs):
#     def validate(self, attrs):
#     def get_station_photos(self, obj):
#     def get_facebook_url(self, obj):
#     def get_twitter_url(self, obj):
# 
# 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/schedules/models.py
# class Transmission(object):
#     """
#     Temporal object generated according to recurrence rules or schedule information
#     It contains concrete dates
#     """
#     def __init__(self, schedule, date, episode=None):
#         self.schedule = schedule
#         self.programme = schedule.programme
#         self.start = date
#         self.episode = episode
# 
#     @property
#     def name(self):
#         return self.programme.name
# 
#     @property
#     def slug(self):
#         return self.programme.slug
# 
#     @property
#     def end(self):
#         return self.start + self.programme.runtime
# 
#     @property
#     def programme_url(self):
#         return reverse('programmes:detail', args=[self.programme.slug])
# 
#     @property
#     def episode_url(self):
#         if not self.episode:
#             return None
#         return reverse(
#             'programmes:episode_detail',
#             args=(self.slug, self.episode.season, self.episode.number_in_season)
#         )
# 
#     @classmethod
#     def at(cls, at):
#         schedules = Schedule.objects.filter(
#             calendar__is_active=True, effective_start_dt__lte=at
#         ).filter(
#             Q(effective_end_dt__gt=at) |
#             Q(effective_end_dt__isnull=True)
#         ).select_related('programme')
#         for schedule in schedules:
#             date = schedule.date_before(at)
#             if date and date <= at < date + schedule.runtime:
#                 # Get episode
#                 try:
#                     episode = Episode.objects.get(issue_date=date)
#                 except Episode.DoesNotExist:
#                     episode = None
#                 # yield transmission
#                 yield cls(schedule, date, episode)
# 
#     @classmethod
#     def between(cls, after, before, schedules=None):
#         """
#         Return a tuple of Schedule and Transmissions sorted by date
#         """
#         if schedules is None:
#             schedules = Schedule.objects.filter(calendar__is_active=True)
# 
#         schedules = schedules.filter(
#             effective_start_dt__lt=before
#         ).filter(
#             Q(effective_end_dt__gt=after) |
#             Q(effective_end_dt__isnull=True)
#         ).select_related('programme')
# 
#         # Querying episodes episodes in that period of time
#         episodes = Episode.objects.filter(
#             issue_date__lt=before, issue_date__gte=after
#         )
#         episodes = {_episode.issue_date: _episode for _episode in episodes}
# 
#         transmission_dates = [
#             map(partial(_return_tuple, item2=schedule), schedule.dates_between(after, before))
#             for schedule in schedules
#         ]
#         sorted_transmission_dates = heapq.merge(*transmission_dates)
#         for sorted_transmission_date, schedule in sorted_transmission_dates:
#             # Adding episodes matching by date, we don't care about if this info is not correct
#             yield cls(schedule, sorted_transmission_date, episodes.get(sorted_transmission_date))


# Path: radioco/apps/api/tests/test_api.py
import datetime
import pytz
from django.test import TestCase, RequestFactory
from rest_framework import status
from radioco.apps.api import serializers
from radioco.apps.radioco.test_utils import TestDataMixin
from radioco.apps.schedules.models import Transmission





MOCK_CONTEXT = {'request': RequestFactory().get('')}


class TestApi(TestDataMixin):

    def test_api(self):
        response = self.client.get('/api/2/')
        self.assertEqual(response.status_code, status.HTTP_200_OK)



class TestSerializers(TestDataMixin, TestCase):