def test_now_playing_2(self): now_mock = datetime.datetime(2014, 1, 7, 0, 0, 0, 0) schedule, date = Schedule.schedule(now_mock) schedule_1 = Schedule.objects.get( programme=Programme.objects.get(name="Programme 00:00 - 09:00"), day=TU) self.assertEqual(schedule_1, schedule) self.assertEqual( datetime.datetime.combine(now_mock, schedule_1.start_hour), date)
def index(request): now = datetime.datetime.now() schedule_now, start_time = Schedule.schedule(now) if schedule_now: end_time = start_time + schedule_now.runtime() percentage = str(round((now - start_time).total_seconds() / schedule_now.runtime().total_seconds() * 100)) else: end_time = now percentage = None next_events = __get_events(end_time, end_time + relativedelta(hours=+16)) other_programmes = Programme.objects.order_by('?').all()[:10] latest_episodes = Episode.objects.filter(podcast__isnull=False).order_by('-issue_date')[:5] context = {'schedule_now':schedule_now, 'start_time':start_time, 'percentage':percentage, 'end_time':end_time, 'now': now, 'next_events':next_events, 'other_programmes':other_programmes, 'latest_episodes':latest_episodes} return render(request, 'radio/index.html', context)
def index(request): now = datetime.datetime.now() schedule_now, start_time = Schedule.schedule(now) if schedule_now: end_time = start_time + schedule_now.runtime() percentage = str(round((now - start_time).total_seconds() / schedule_now.runtime().total_seconds() * 100)) else: end_time = now percentage = None next_events = __get_events(end_time, end_time + relativedelta(hours=+16)) other_programmes = Programme.objects.order_by('?').all()[:10] latest_episodes = Episode.objects.filter(podcast__isnull=False).order_by('-issue_date')[:5] context = { 'schedule_now': schedule_now, 'start_time': start_time, 'percentage': percentage, 'end_time': end_time, 'now': now, 'next_events': next_events, 'other_programmes': other_programmes, 'latest_episodes': latest_episodes } return render(request, 'radio/index.html', context)
def test_now_playing_2(self): now_mock = datetime.datetime(2014, 1, 7, 0, 0, 0, 0) schedule, date = Schedule.schedule(now_mock) schedule_1 = Schedule.objects.get(programme=Programme.objects.get(name="Programme 00:00 - 09:00"), day=TU) self.assertEqual(schedule_1, schedule) self.assertEqual(datetime.datetime.combine(now_mock, schedule_1.start_hour), date)