Ticket #15144: tests_demonstrating_regression.diff

File tests_demonstrating_regression.diff, 1.7 KB (added by jsdalton, 4 years ago)
  • tests/regressiontests/cache/tests.py

     
    12011201
    12021202        other_view = cache_page(cache='other')(view)
    12031203        other_with_prefix_view = cache_page(cache='other', key_prefix='prefix2')(view)
    1204 
     1204        other_with_timeout_view = cache_page(4, cache='other', key_prefix='prefix3')(view)
     1205       
    12051206        factory = RequestFactory()
    12061207        request = factory.get('/view/')
    12071208
     
    12401241        # And prefixing the alternate cache yields yet another cache entry
    12411242        response = other_with_prefix_view(request, '9')
    12421243        self.assertEquals(response.content, 'Hello World 9')
    1243 
     1244       
     1245        # Request from the alternate cache with a new prefix and a custom timeout
     1246        response = other_with_timeout_view(request, '20')
     1247        self.assertEquals(response.content, 'Hello World 20')
     1248       
    12441249        # But if we wait a couple of seconds...
    12451250        time.sleep(2)
    12461251
     
    12681273        # .. even if it has a prefix
    12691274        response = other_with_prefix_view(request, '15')
    12701275        self.assertEquals(response.content, 'Hello World 15')
     1276       
     1277        # ... but a view with a custom timeout will still hit
     1278        response = other_with_timeout_view(request, '21')
     1279        self.assertEquals(response.content, 'Hello World 20')
     1280       
     1281        # And if we wait a few more seconds
     1282        time.sleep(2)
     1283       
     1284        # the custom timeouot cache will miss
     1285        response = other_with_timeout_view(request, '22')
     1286        self.assertEquals(response.content, 'Hello World 22')
    12711287
    12721288if __name__ == '__main__':
    12731289    unittest.main()
Back to Top