Ejemplo n.º 1
0
 def test_cache(self):
     self.assertIsNone(get_cache_version())
     self.assertIsNone(get_cached_manifest())
     set_cached_manifest("ciao")
     self.assertEqual(get_cache_version(), 1)
     self.assertEqual(get_cached_manifest(), "ciao")
     reset_cache_manifest()
     set_cached_value("nociao", 1)
     self.assertEqual(get_cached_manifest(), "ciao")
     self.assertEqual(get_cache_version(), 2)
Ejemplo n.º 2
0
 def test_cache(self):
     self.assertIsNone(get_cache_version())
     self.assertIsNone(get_cached_manifest())
     set_cached_manifest("ciao")
     self.assertEqual(get_cache_version(), 1)
     self.assertEqual(get_cached_manifest(), "ciao")
     reset_cache_manifest()
     set_cached_value("nociao", 1)
     self.assertEqual(get_cached_manifest(), "ciao")
     self.assertEqual(get_cache_version(), 2)
Ejemplo n.º 3
0
 def get_manifest(self, update=False):
     """
     Either get the manifest file out of the cache or render it and save in
     the cache.
     """
     if not is_manifest_clean() and update:
         self.context = {
             'version':
             self.get_version_timestamp(),
             'date':
             datetime.fromtimestamp(self.get_version_timestamp() /
                                    1000000).isoformat(),
             'cached_urls':
             sorted(self.get_cached_urls()),
             'network_urls':
             sorted(self.get_network_urls()),
             'fallback_urls':
             self.get_fallback_urls(),
         }
         context = RequestContext(self.request, self.context)
         manifest = render_to_string(self._template,
                                     context_instance=context)
         set_cached_manifest(manifest)
         return manifest
     else:
         return get_cached_manifest()
Ejemplo n.º 4
0
 def test_command_view_equivalent(self):
     request = self.get_request("/", user=self.admin)
     view = ManifestAppCache.as_view(appcache_update=1)
     response = view(request)
     # version / date / comments removed as we're interested in
     # extracted urls. stripped for the same reason
     manifest_view = re.sub("# (date|version).+", "", response.content).strip()
     clear_cache_manifest()
     call_command("update_manifest")
     # version / date / comments removed as we're interested in
     # extracted urls. stripped for the same reason
     manifest_command = re.sub("# (date|version).+", "", get_cached_manifest()).strip()
     self.assertEqual(manifest_command, manifest_view)
Ejemplo n.º 5
0
 def test_command_view_equivalent(self):
     request = self.get_request('/', user=self.admin)
     view = ManifestAppCache.as_view(appcache_update=1)
     response = view(request)
     # version / date / comments removed as we're interested in
     # extracted urls. stripped for the same reason
     manifest_view = re.sub("# (date|version).+", "",
                            response.content).strip()
     clear_cache_manifest()
     call_command("update_manifest")
     # version / date / comments removed as we're interested in
     # extracted urls. stripped for the same reason
     manifest_command = re.sub("# (date|version).+", "",
                               get_cached_manifest()).strip()
     self.assertEqual(manifest_command, manifest_view)
 def get_manifest(self, update=False):
     """
     Either get the manifest file out of the cache or render it and save in
     the cache.
     """
     if not is_manifest_clean() and update:
         self.context = {
             'version': self.get_version_timestamp(),
             'date': datetime.fromtimestamp(self.get_version_timestamp()/1000000).isoformat(),
             'cached_urls': sorted(self.get_cached_urls()),
             'network_urls': sorted(self.get_network_urls()),
             'fallback_urls': self.get_fallback_urls(),
         }
         context = RequestContext(self.request, self.context)
         manifest = render_to_string(self._template, context_instance=context)
         set_cached_manifest(manifest)
         return manifest
     else:
         return get_cached_manifest()