def setUp(self):
        # Call the super setup
        super(EventManagerQuerySetTest, self).setUp()

        # Create a query set reference
        self.queryset = EventQuerySet()

        # Create a manager reference
        self.manager = EventManager()
    def setUp(self):
        # Call the super setup
        super(EventManagerQuerySetTest, self).setUp()

        # Create a query set reference
        self.queryset = EventQuerySet()

        # Create a manager reference
        self.manager = EventManager()
class EventManagerQuerySetTest(TestCase):
    def setUp(self):
        # Call the super setup
        super(EventManagerQuerySetTest, self).setUp()

        # Create a query set reference
        self.queryset = EventQuerySet()

        # Create a manager reference
        self.manager = EventManager()

    def test_mark_seen(self):
        event = G(Event, context={})
        medium = G(Medium)
        Event.objects.mark_seen(medium)
        self.assertEqual(EventSeen.objects.count(), 1)
        self.assertTrue(
            EventSeen.objects.filter(event=event, medium=medium).exists())

    @patch('entity_event.context_loader.load_contexts_and_renderers',
           spec_set=True)
    def test_load_contexts_and_renderers(self,
                                         mock_load_contexts_and_renderers):
        e = G(Event, context={})
        medium = G(Medium)
        Event.objects.load_contexts_and_renderers(medium)
        self.assertEquals(mock_load_contexts_and_renderers.call_count, 1)
        self.assertEquals(
            list(mock_load_contexts_and_renderers.call_args_list[0][0][0]),
            [e])
        self.assertEquals(
            mock_load_contexts_and_renderers.call_args_list[0][0][1], [medium])

    @patch.object(EventManager, 'get_queryset', autospec=True)
    def test_cache_related(self, mock_get_queryset):
        # Setup some mock return values
        mock_get_queryset.return_value = Mock(EventQuerySet(), autospec=True)

        # Call the method
        self.manager.cache_related()

        # Assert that we called get queryset
        mock_get_queryset.assert_called_once_with(self.manager)
class EventManagerQuerySetTest(TestCase):
    def setUp(self):
        # Call the super setup
        super(EventManagerQuerySetTest, self).setUp()

        # Create a query set reference
        self.queryset = EventQuerySet()

        # Create a manager reference
        self.manager = EventManager()

    def test_mark_seen(self):
        event = G(Event, context={})
        medium = G(Medium)
        Event.objects.mark_seen(medium)
        self.assertEqual(EventSeen.objects.count(), 1)
        self.assertTrue(EventSeen.objects.filter(event=event, medium=medium).exists())

    @patch('entity_event.context_loader.load_contexts_and_renderers', spec_set=True)
    def test_load_contexts_and_renderers(self, mock_load_contexts_and_renderers):
        e = G(Event, context={})
        medium = G(Medium)
        Event.objects.load_contexts_and_renderers(medium)
        self.assertEquals(mock_load_contexts_and_renderers.call_count, 1)
        self.assertEquals(list(mock_load_contexts_and_renderers.call_args_list[0][0][0]), [e])
        self.assertEquals(mock_load_contexts_and_renderers.call_args_list[0][0][1], [medium])

    @patch.object(EventManager, 'get_queryset', autospec=True)
    def test_cache_related(self, mock_get_queryset):
        # Setup some mock return values
        mock_get_queryset.return_value = Mock(EventQuerySet(), autospec=True)

        # Call the method
        self.manager.cache_related()

        # Assert that we called get queryset
        mock_get_queryset.assert_called_once_with(self.manager)