'Ensure that the Cache control headers are properly set'

def test_cache_control(self):

    content = u'abc'
    h = hashlib.md5(content.encode(u'utf-8')).hexdigest()
    filename = u'file.{0}.data'.format(h)
    with open(os.path.join(self.build_path, filename), u'w') as f:
        f.write(content)
    p = TestHeadersPlugin()
    self.site.plugin_manager.loaders = [ObjectsPluginLoader([p, CacheDurationPlugin()])]
    self.site.plugin_manager.reload()
    self.site.plugin_manager.preDeploy(self.site)
    f = TestFile(self.engine, filename)
    f.upload()
    self.assertEqual(p.file.cache_control, f.MAX_CACHE_EXPIRATION)
    with open(os.path.join(self.build_path, u'123.html'), u'w') as f:
        f.write(u'abc')
    p = TestHeadersPlugin()
    self.site.plugin_manager.loaders = [ObjectsPluginLoader([p, CacheDurationPlugin()])]
    self.site.plugin_manager.reload()
    f = TestFile(self.engine, u'123.html')
    self.site.config.set(u'cache-duration', None)
    self.site.plugin_manager.preDeploy(self.site)
    f.upload()
    self.assertEqual(p.file.cache_control, f.DEFAULT_CACHE_EXPIRATION)
    self.site.config.set(u'cache-duration', 123)
    self.site.plugin_manager.preDeploy(self.site)
    f.upload()
    self.assertEqual(p.file.cache_control, 123)
