class CacheInvalidateMixinTests(TestCase):
    """
    Tests for django_cache_manager.mixins.CacheInvalidateMixin
    """
    def setUp(self):
        self.mixin = CacheInvalidateMixin()
        self.mixin.model = Manufacturer()

    @patch('django_cache_manager.models.uuid')
    def test_invalidate_model_cache(self, mock_uuid, mock_model_cache):
        """
        Mixin broadcasts new model cache info when a model is invalidated
        """
        mock_uuid4 = Mock(hex='unique_id')
        mock_uuid.uuid4.return_value = mock_uuid4
        self.mixin.invalidate_model_cache()
        self.assertEquals(mock_model_cache.share_model_cache_info.call_count,
                          2)
class CacheInvalidateMixinTests(TestCase):
    """
    Tests for django_cache_manager.mixins.CacheInvalidateMixin
    """

    def setUp(self):
        self.mixin = CacheInvalidateMixin()
        self.mixin.model = Manufacturer()

    @patch('django_cache_manager.models.uuid')
    def test_invalidate_model_cache(self, mock_uuid, mock_model_cache):
        """
        Mixin broadcasts new model cache info when a model is invalidated
        """
        mock_uuid4 = Mock(hex='unique_id')
        mock_uuid.uuid4.return_value = mock_uuid4
        self.mixin.invalidate_model_cache()
        self.assertEquals(mock_model_cache.share_model_cache_info.call_count, 2)
class CacheInvalidateMixinTests(TestCase):
    """
    Tests for django_cache_manager.mixins.CacheInvalidateMixin
    """
    def setUp(self):
        self.mixin = CacheInvalidateMixin()
        self.mixin.model = Manufacturer()

    @patch('django_cache_manager.mixins.uuid')
    def test_invalidate_model_cache(self, mock_uuid, mock_model_cache):
        """
        Mixin broadcasts new model cache info when a model is invalidated
        """
        mock_uuid4 = Mock(hex='unique_id')
        mock_uuid.uuid4.return_value = mock_uuid4
        self.mixin.invalidate_model_cache()
        mock_model_cache.share_model_cache_info.assert_called_once_with(
            ModelCacheInfo(table_name=u'tests_manufacturer',
                           table_key='unique_id'))
 def setUp(self):
     self.mixin = CacheInvalidateMixin()
     self.mixin.model = Manufacturer()
 def setUp(self):
     self.mixin = CacheInvalidateMixin()
     self.mixin.model = Manufacturer()