コード例 #1
0
  def testInlineStylesheetURLs(self):
    file_contents = {}
    file_contents[os.path.normpath('/tmp/a/b/my_component.html')] = """
<!DOCTYPE html>
<style>
.some-rule {
    background-image: url('../something.jpg');
}
</style>
"""
    file_contents[os.path.normpath('/tmp/a/something.jpg')] = 'jpgdata'
    with fake_fs.FakeFS(file_contents):
      project = project_module.Project([
          os.path.normpath('/py_vulcanize/'), os.path.normpath('/tmp/')])
      loader = resource_loader.ResourceLoader(project)
      my_component = loader.LoadModule(module_name='a.b.my_component')

      computed_deps = []
      my_component.AppendDirectlyDependentFilenamesTo(computed_deps)
      self.assertEquals(set(computed_deps),
                        set([os.path.normpath('/tmp/a/b/my_component.html'),
                             os.path.normpath('/tmp/a/something.jpg')]))

      f = six.StringIO()
      ctl = html_generation_controller.HTMLGenerationController()
      my_component.AppendHTMLContentsToFile(f, ctl)
      html = f.getvalue().rstrip()
      # FIXME: This is apparently not used.
      expected_html = """
.some-rule {
    background-image: url(data:image/jpg;base64,anBnZGF0YQ==);
}
""".rstrip()
コード例 #2
0
 def html_contents_without_links_and_script(self):
     return self.GenerateHTML(
         html_generation_controller.HTMLGenerationController())