def test_queryset(self):
     GigEventFactory(date=make_date('2017-02-09'))
     CinemaEventFactory(date=make_date('2017-02-10'))
     GigEventFactory(date=make_date('2017-02-10'))
     CinemaEventFactory(date=make_date('2017-02-11'))
     qs = day_events(make_date('2017-02-10'))
     self.assertEqual(len(qs), 2)
    def test_filters_by_event_kind(self):
        "It should only count events of the supplied event_kind."

        # It should include c1 and c2 as both have > 1 GigEvent:

        c1 = IndividualCreatorFactory()
        EventRoleFactory(event=GigEventFactory(), creator=c1)
        EventRoleFactory(event=GigEventFactory(), creator=c1)
        EventRoleFactory(event=GigEventFactory(), creator=c1)
        EventRoleFactory(event=CinemaEventFactory(), creator=c1)

        c2 = IndividualCreatorFactory()
        EventRoleFactory(event=GigEventFactory(), creator=c2)
        EventRoleFactory(event=GigEventFactory(), creator=c2)

        c3 = IndividualCreatorFactory()
        EventRoleFactory(event=CinemaEventFactory(), creator=c3)
        EventRoleFactory(event=CinemaEventFactory(), creator=c3)

        data = most_seen_creators_card(event_kind='gig')

        self.assertIn('object_list', data)
        self.assertEqual(len(data['object_list']), 2)
        self.assertEqual(data['object_list'][0], c1)
        self.assertEqual(data['object_list'][0].num_events, 3)
        self.assertEqual(data['object_list'][1], c2)
        self.assertEqual(data['object_list'][1].num_events, 2)
 def test_result(self):
     GigEventFactory(date=make_date('2017-02-09'))
     CinemaEventFactory(date=make_date('2017-02-10'))
     GigEventFactory(date=make_date('2017-02-10'))
     CinemaEventFactory(date=make_date('2017-02-11'))
     result = day_events_card(make_date('2017-02-10'))
     self.assertEqual(result['card_title'], 'Events on 10 Feb 2017')
     self.assertEqual(len(result['event_list']), 2)
 def test_queryset(self):
     "It should return 10 recent events by default."
     CinemaEventFactory.create_batch(6, date=make_date('2017-02-10'))
     GigEventFactory.create_batch(6, date=make_date('2017-02-12'))
     qs = recent_events()
     self.assertEqual(len(qs), 10)
     self.assertEqual(qs[5].kind, 'gig')
     self.assertEqual(qs[6].kind, 'cinema')
    def setUp(self):
        super().setUp()
        CinemaEventFactory.create_batch(1, date=make_date('2015-01-01'))
        GigEventFactory.create_batch(2, date=make_date('2015-06-01'))

        TheatreEventFactory.create_batch(1, date=make_date('2017-01-01'))

        GigEventFactory.create_batch(1, date=make_date('2018-01-01'))
        TheatreEventFactory.create_batch(1, date=make_date('2018-01-01'))
 def test_result(self):
     GigEventFactory(date=make_date('2017-02-09'))
     CinemaEventFactory(date=make_date('2017-02-10'))
     GigEventFactory(date=make_date('2015-02-09'))
     result = events_years()
     self.assertEqual(len(result), 2)
     self.assertEqual(result[0], make_date('2015-01-01'))
     self.assertEqual(result[1], make_date('2017-01-01'))
 def test_result(self):
     GigEventFactory(date=make_date('2017-02-09'))
     CinemaEventFactory(date=make_date('2017-02-10'))
     GigEventFactory(date=make_date('2015-02-09'))
     result = events_years_card(make_date('2017-01-01'))
     self.assertEqual(result['current_year'], make_date('2017-01-01'))
     self.assertEqual(len(result['years']), 2)
     self.assertEqual(result['years'][0], make_date('2015-01-01'))
     self.assertEqual(result['years'][1], make_date('2017-01-01'))
 def test_context_recent_events(self):
     "It should have recent Events in the context."
     g1 = GigEventFactory(  date=make_date('2017-02-20'))
     g2 = GigEventFactory(  date=make_date('2017-02-05'))
     m1 = CinemaEventFactory(date=make_date('2017-02-10'))
     response = views.HomeView.as_view()(self.request)
     context = response.context_data
     self.assertIn('recent_event_list', context)
     self.assertEqual(len(context['recent_event_list']), 3)
     self.assertEqual(context['recent_event_list'][0], g1)
     self.assertEqual(context['recent_event_list'][1], m1)
     self.assertEqual(context['recent_event_list'][2], g2)