def testGenerateHtmlIndexTupleDupe(self):
   """Verifies GenerateHtmlIndex gives us something unique (input: tuple)"""
   index = os.path.join(self.tempdir, 'index.html')
   files = ('file1', 'file1', 'file1',)
   commands.GenerateHtmlIndex(index, files)
   html = osutils.ReadFile(index)
   self.assertEqual(html.count('>file1</a>'), 1)
 def testGenerateHtmlIndexTuple(self):
   """Verifies GenerateHtmlIndex gives us something sane (input: tuple)"""
   index = os.path.join(self.tempdir, 'index.html')
   files = ('file1', 'monkey tree', 'flying phone',)
   commands.GenerateHtmlIndex(index, files)
   html = osutils.ReadFile(index)
   for f in files:
     # TODO(build): Use assertIn w/python-2.7.
     self.assertTrue('>%s</a>' % f in html)
 def testGenerateHtmlIndexFile(self):
   """Verifies GenerateHtmlIndex gives us something sane (input: file)"""
   index = os.path.join(self.tempdir, 'index.html')
   files = ('a.tgz', 'b b b.txt', 'c', 'dalsdkjfasdlkf',)
   filelist = os.path.join(self.tempdir, 'listing')
   osutils.WriteFile(filelist, '\n'.join(files))
   commands.GenerateHtmlIndex(index, filelist)
   html = osutils.ReadFile(index)
   for f in files:
     # TODO(build): Use assertIn w/python-2.7.
     self.assertTrue('>%s</a>' % f in html)
 def testGenerateHtmlIndexDir(self):
   """Verifies GenerateHtmlIndex gives us something sane (input: dir)"""
   index = os.path.join(self.tempdir, 'index.html')
   files = ('a', 'b b b', 'c', 'dalsdkjfasdlkf',)
   simple_dir = os.path.join(self.tempdir, 'dir')
   for f in files:
     osutils.Touch(os.path.join(simple_dir, f), makedirs=True)
   commands.GenerateHtmlIndex(index, files)
   html = osutils.ReadFile(index)
   for f in files:
     # TODO(build): Use assertIn w/python-2.7.
     self.assertTrue('>%s</a>' % f in html)
 def testGenerateHtmlIndexTuplePretty(self):
   """Verifies GenerateHtmlIndex gives us something pretty (input: tuple)"""
   index = os.path.join(self.tempdir, 'index.html')
   files = ('..|up', 'f.txt|MY FILE', 'm.log|MONKEY', 'b.bin|Yander',)
   commands.GenerateHtmlIndex(index, files)
   html = osutils.ReadFile(index)
   osutils.WriteFile('/tmp/foo.html', html)
   for f in files:
     a = f.split('|')
     # TODO(build): Use assertIn w/python-2.7.
     self.assertTrue('href="%s"' % a[0] in html)
     self.assertTrue('>%s</a>' % a[1] in html)