# Path: radioco/apps/programmes/models.py
# class Programme(models.Model):
#     class Meta:
#         verbose_name = _('programme')
#         verbose_name_plural = _('programmes')
#         permissions = (("see_all_programmes", "Can see all programmes"),)
# 
#     CATEGORY_CHOICES = (
#         ('Arts', _('Arts')),
#         ('Business', _('Business')),
#         ('Comedy', _('Comedy')),
#         ('Education', _('Education')),
#         ('Games & Hobbies', _('Games & Hobbies')),
#         ('Government & Organizations', _('Government & Organizations')),
#         ('Health', _('Health')),
#         ('Kids & Family', _('Kids & Family')),
#         ('Music', _('Music')),
#         ('News & Politics', _('News & Politics')),
#         ('Religion & Spirituality', _('Religion & Spirituality')),
#         ('Science & Medicine', _('Science & Medicine')),
#         ('Society & Culture', _('Society & Culture')),
#         ('Sports & Recreation', _('Sports & Recreation')),
#         ('Technology', _('Technology')),
#         ('TV & Film', _('TV & Film')),
#     )
# 
#     name = models.CharField(
#         max_length=100, unique=True, verbose_name=_("name")
#     )
#     announcers = models.ManyToManyField(
#         User, blank=True, through='Role', verbose_name=_("announcers")
#     )
#     synopsis = RichTextUploadingField(blank=True, verbose_name=_("synopsis"))
#     photo = models.ImageField(
#         upload_to='photos/', default='defaults/default-programme-photo.jpg', verbose_name=_("photo")
#     )
#     language = models.CharField(
#         default=PROGRAMME_LANGUAGES[0][0], verbose_name=_("language"),
#         choices=[(k_v[0], _(k_v[1])) for k_v in PROGRAMME_LANGUAGES], max_length=7
#     )
#     # XXX ensure not decreasing
#     current_season = models.PositiveIntegerField(
#         validators=[MinValueValidator(1)], verbose_name=_("current season")
#     )
#     category = models.CharField(
#         blank=True, null=True, max_length=50, choices=CATEGORY_CHOICES, verbose_name=_("category")
#     )
#     slug = models.SlugField(max_length=100, unique=True,
#         help_text=_("Please DON'T change this value. It's used to build URL's."))
#     _runtime = models.PositiveIntegerField(
#         validators=[MinValueValidator(1)], verbose_name=_("runtime"), help_text=_("In minutes."))
# 
#     start_date = models.DateField(blank=True, null=True, verbose_name=_('start date'))
#     end_date = models.DateField(blank=True, null=True, verbose_name=_('end date'))
# 
#     @property
#     def synopsis_text(self):
#         return BeautifulSoup(self.synopsis, "html.parser").text
# 
#     @property
#     def runtime(self):
#         if not self._runtime:
#             raise FieldError(_('Runtime not set'))
#         return datetime.timedelta(minutes=self._runtime)
# 
#     @runtime.setter
#     def runtime(self, value):
#         self._runtime = value
# 
#     @property
#     def start_dt(self):
#         if not self.start_date:
#             return None
#         tz = timezone.get_default_timezone()
#         return tz.localize(datetime.datetime.combine(self.start_date, datetime.time())).astimezone(pytz.utc)
# 
#     @property
#     def end_dt(self):
#         if not self.end_date:
#             return None
#         tz = timezone.get_default_timezone()
#         return tz.localize(datetime.datetime.combine(self.end_date, datetime.time(23, 59, 59))).astimezone(pytz.utc)
# 
#     def save(self, *args, **kwargs):
#         if not self.slug:
#             self.slug = slugify(self.name)
#         super(Programme, self).save(*args, **kwargs)
# 
#     def rearrange_episodes(self, after, calendar):
#         """
#         Update the issue_date of episodes from a given date
#         """
#         episodes = Episode.objects.unfinished(self, after)
#         dates = next_dates(calendar, self, after)
# 
#         # Further dates and episodes available -> re-order
#         while True:
#             try:
#                 date = next(dates)
#                 episode = next(episodes)
#             except StopIteration:
#                 break
#             else:
#                 episode.issue_date = date
#                 episode.save()
# 
#         # No further dates available -> unschedule
#         while True:
#             try:
#                 episode = next(episodes)
#             except StopIteration:
#                 break
#             else:
#                 episode.issue_date = None
#                 episode.save()
# 
#     def get_absolute_url(self):
#         return reverse('programmes:detail', args=[self.slug])
# 
#     def __str__(self):
#         return "%s" % (self.name)
# 
# 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.programmes.models import Programme
from radioco.apps.radioco.test_utils import TestDataMixin




def mock_now():
    return pytz.utc.localize(datetime.datetime(2015, 1, 6, 14, 30, 0))


class TestProgramme(TestDataMixin, APITestCase):
    def setUp(self):

# Path: radioco/apps/programmes/models.py
# class Programme(models.Model):
#     class Meta:
#         verbose_name = _('programme')
#         verbose_name_plural = _('programmes')
#         permissions = (("see_all_programmes", "Can see all programmes"),)
# 
#     CATEGORY_CHOICES = (
#         ('Arts', _('Arts')),
#         ('Business', _('Business')),
#         ('Comedy', _('Comedy')),
#         ('Education', _('Education')),
#         ('Games & Hobbies', _('Games & Hobbies')),
#         ('Government & Organizations', _('Government & Organizations')),
#         ('Health', _('Health')),
#         ('Kids & Family', _('Kids & Family')),
#         ('Music', _('Music')),
#         ('News & Politics', _('News & Politics')),
#         ('Religion & Spirituality', _('Religion & Spirituality')),
#         ('Science & Medicine', _('Science & Medicine')),
#         ('Society & Culture', _('Society & Culture')),
#         ('Sports & Recreation', _('Sports & Recreation')),
#         ('Technology', _('Technology')),
#         ('TV & Film', _('TV & Film')),
#     )
# 
#     name = models.CharField(
#         max_length=100, unique=True, verbose_name=_("name")
#     )
#     announcers = models.ManyToManyField(
#         User, blank=True, through='Role', verbose_name=_("announcers")
#     )
#     synopsis = RichTextUploadingField(blank=True, verbose_name=_("synopsis"))
#     photo = models.ImageField(
#         upload_to='photos/', default='defaults/default-programme-photo.jpg', verbose_name=_("photo")
#     )
#     language = models.CharField(
#         default=PROGRAMME_LANGUAGES[0][0], verbose_name=_("language"),
#         choices=[(k_v[0], _(k_v[1])) for k_v in PROGRAMME_LANGUAGES], max_length=7
#     )
#     # XXX ensure not decreasing
#     current_season = models.PositiveIntegerField(
#         validators=[MinValueValidator(1)], verbose_name=_("current season")
#     )
#     category = models.CharField(
#         blank=True, null=True, max_length=50, choices=CATEGORY_CHOICES, verbose_name=_("category")
#     )
#     slug = models.SlugField(max_length=100, unique=True,
#         help_text=_("Please DON'T change this value. It's used to build URL's."))
#     _runtime = models.PositiveIntegerField(
#         validators=[MinValueValidator(1)], verbose_name=_("runtime"), help_text=_("In minutes."))
# 
#     start_date = models.DateField(blank=True, null=True, verbose_name=_('start date'))
#     end_date = models.DateField(blank=True, null=True, verbose_name=_('end date'))
# 
#     @property
#     def synopsis_text(self):
#         return BeautifulSoup(self.synopsis, "html.parser").text
# 
#     @property
#     def runtime(self):
#         if not self._runtime:
#             raise FieldError(_('Runtime not set'))
#         return datetime.timedelta(minutes=self._runtime)
# 
#     @runtime.setter
#     def runtime(self, value):
#         self._runtime = value
# 
#     @property
#     def start_dt(self):
#         if not self.start_date:
#             return None
#         tz = timezone.get_default_timezone()
#         return tz.localize(datetime.datetime.combine(self.start_date, datetime.time())).astimezone(pytz.utc)
# 
#     @property
#     def end_dt(self):
#         if not self.end_date:
#             return None
#         tz = timezone.get_default_timezone()
#         return tz.localize(datetime.datetime.combine(self.end_date, datetime.time(23, 59, 59))).astimezone(pytz.utc)
# 
#     def save(self, *args, **kwargs):
#         if not self.slug:
#             self.slug = slugify(self.name)
#         super(Programme, self).save(*args, **kwargs)
# 
#     def rearrange_episodes(self, after, calendar):
#         """
#         Update the issue_date of episodes from a given date
#         """
#         episodes = Episode.objects.unfinished(self, after)
#         dates = next_dates(calendar, self, after)
# 
#         # Further dates and episodes available -> re-order
#         while True:
#             try:
#                 date = next(dates)
#                 episode = next(episodes)
#             except StopIteration:
#                 break
#             else:
#                 episode.issue_date = date
#                 episode.save()
# 
#         # No further dates available -> unschedule
#         while True:
#             try:
#                 episode = next(episodes)
#             except StopIteration:
#                 break
#             else:
#                 episode.issue_date = None
#                 episode.save()
# 
#     def get_absolute_url(self):
#         return reverse('programmes:detail', args=[self.slug])
# 
#     def __str__(self):
#         return "%s" % (self.name)
# 
# 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_radiocom_api.py
import datetime
import mock
import pytz
from rest_framework import status
from rest_framework.test import APITestCase
from radioco.apps.programmes.models import Programme
from radioco.apps.radioco.test_utils import TestDataMixin





def mock_now():
    return pytz.utc.localize(datetime.datetime(2015, 1, 6, 14, 30, 0))


class TestProgramme(TestDataMixin, APITestCase):
    def setUp(self):

        self.summer_programme = Programme.objects.create(