@@ -18,18 +18,19 @@ def __init__(self, *args, **kwargs):
18
18
super (FragmentCacheInvalidation , self ).__init__ (* args , ** kwargs )
19
19
20
20
def setUp (self ):
21
- pass
21
+ cache . clear ()
22
22
23
23
def tearDown (self ):
24
24
pass
25
25
26
26
def test_version_at_creation (self ):
27
27
comment = Comment .objects .latest ()
28
+ comment .like_it ()
28
29
version_cache_key = cache_token_key_for_record (comment )
29
30
# the cache version token should be zero as we've just created the record
30
31
# by loading the fixtures. At creation the cache version should be
31
32
# zero
32
- self .assertTrue (cache .get (version_cache_key ))
33
+ self .assertEquals (cache .get (version_cache_key ), 0 )
33
34
34
35
def test_version_after_save (self ):
35
36
# get the comment we want to invalidate the cache for
@@ -38,11 +39,9 @@ def test_version_after_save(self):
38
39
version_cache_key = cache_token_key_for_record (comment )
39
40
# get the original version, should be zero
40
41
original_version = cache .get (version_cache_key , None )
41
- self .assertNotEquals (original_version , None )
42
42
# change the comment & save, should increment the version value in
43
43
# memcached
44
44
comment .like_it ()
45
- comment .save ()
46
45
# get the new version value for the comment
47
46
new_version = cache .get (version_cache_key )
48
47
self .assertNotEquals (original_version , new_version )
@@ -71,7 +70,6 @@ def test_fragment_cache_miss(self):
71
70
72
71
# modifying the model should change the cache
73
72
comment .like_it ()
74
- comment .save ()
75
73
76
74
# assert the changed cache key
77
75
new_cache_key = generate_fragment_cache_key_for_record (comment , "comment.xml" )
@@ -89,7 +87,14 @@ def test_modelsweeper_mixin(self):
89
87
tmm .save ()
90
88
self .assertEquals (tmm .cachesweeper_version , 1 )
91
89
92
- def test_modelsweeper_attr (self ):
93
- tam = TestAttributeModel (text = 'testing text' )
94
- tam .save ()
95
-
90
+ def test_default_version_zero (self ):
91
+ tmm = TestMixinModel (text = 'testing text' )
92
+ tmm .save ()
93
+ cache .delete (tmm .cachesweeper_version_key )
94
+ self .assertEquals (tmm .cachesweeper_version , 0 )
95
+ tmm .save ()
96
+ self .assertEquals (tmm .cachesweeper_version , 1 )
97
+
98
+ # def test_modelsweeper_manager(self):
99
+ # tmm = TestManagerModel(text='testing text')
100
+ # self.assertTrue(hasattr(tmm.cachesweeper,'cachesweeper'))
0 commit comments