Exemplo n.º 1
0
    def test_clear_cache(self):
        from edwin.models.photo import Photo
        photo = Photo(self.photo_file)
        photo.id = '123456'

        from edwin.views.image import ImageApplication
        app = ImageApplication(self.tmpdir)
        version = app.version(photo, (300, 300))

        import os
        import webob
        cache_file = os.path.join(self.tmpdir, '123456.300x300.jpg')
        request = webob.Request.blank('/image/123456.300x300.jpg')
        request.app_context = DummyAppContextCatalog(photo)
        request.authenticated_principals = ['group.Administrators']
        app(request, version['fname'])

        self.failUnless(os.path.exists(cache_file))
        app.clear_cache()
        self.failIf(os.path.exists(cache_file))