import datetime
import unittest

import mock
from django.core.urlresolvers import reverse
from django.test import TestCase, override_settings, RequestFactory

from conference.tests.factories.attendee_profile import AttendeeProfileFactory
from conference.tests.factories.conference import ConferenceFactory

from django_factory_boy import auth as auth_factories

from conference.tests.factories.event import TrackWithEventsFactory
from p3.tests.factories.schedule import ScheduleFactory
from p3.tests.factories.track import TrackFactory


class TestLiveViews(TestCase):
    def setUp(self):
        self.user = auth_factories.UserFactory(password='password1234', is_superuser=True)
        is_logged = self.client.login(username=self.user.username,
                                      password='password1234')
        AttendeeProfileFactory(user=self.user)
        self.assertTrue(is_logged)

    @override_settings(CONFERENCE='epbeta', DEBUG=False)
    def test_live_conference(self):
        tmp = ConferenceFactory(code='epbeta', conference_start=datetime.date.today())
        from p3.views.live import _live_conference

        conf, _ = _live_conference()

        self.assertEqual(tmp, conf)

    @override_settings(CONFERENCE='epbeta', DEBUG=False)
    def test_live(self):
        ConferenceFactory(code='epbeta', conference_start=datetime.date.today())
        url = reverse('p3-live')
        response = self.client.get(url)

        self.assertEqual(response.templates[0].name, 'p3/live.html')
        self.assertEqual(response.context['tracks'].count(), 0)

    @override_settings(CONFERENCE='epbeta', DEBUG=False)
    def test_p3_live_track_events(self):
        # p3-live-track-events -> p3.views.live.live_track_events
        conference = ConferenceFactory(code='epbeta', conference_start=datetime.date.today())
        schedule = ScheduleFactory(conference=conference, date=datetime.date.today())
        track = TrackFactory(schedule=schedule)

        # FIXME: track_with_events = TrackWithEventsFactory()

        url = reverse('p3-live-track-events', kwargs={
            'track': track.track,
        })
        response = self.client.get(url)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.get('content-type'), 'application/json')
        self.assertJSONEqual(response.content, [])

    @unittest.skip("FIXME")
    def test_p3_live_events(self):
        # p3-live-events -> p3.views.live.live_events
        url = reverse('p3-live-events')
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

@@ -359,76 +359,8 @@
 es%0A%0A
-from conference.tests.factories.event import TrackWithEventsFactory%0A
 from
@@ -2282,29 +2282,58 @@
    @
-unittest.skip(%22FIXME%22
+override_settings(CONFERENCE='epbeta', DEBUG=False
 )%0A  
@@ -2459,16 +2459,251 @@
 vents')%0A
+        conference = ConferenceFactory(code='epbeta', conference_start=datetime.date.today())%0A        schedule = ScheduleFactory(conference=conference, date=conference.conference_start)%0A        track = TrackFactory(schedule=schedule)%0A%0A
         
@@ -2734,16 +2734,17 @@
 et(url)%0A
+%0A
         
@@ -2767,28 +2767,153 @@
 (response.status_code, 200)%0A
+        self.assertEqual(response.get('content-type'), 'application/json')%0A        self.assertJSONEqual(response.content, %7B%7D)

Add a new test for test_p3_live_events