from buildfarm import util
-class CountLinesTests(unittest.TestCase):
-
- def test_simple(self):
- self.assertEquals(2, util.count_lines("foo\nbar"))
- self.assertEquals(1, util.count_lines("bar"))
- self.assertEquals(1, util.count_lines(""))
-
-
-class ChangeExtensionTests(unittest.TestCase):
-
- def test_simple(self):
- self.assertEquals("foo.bar", util.ChangeExtension("foo.old", "bar"))
- self.assertEquals("foo.png", util.ChangeExtension("foo.png", "png"))
- self.assertEquals("foobar.png", util.ChangeExtension("foobar", "png"))
-
-
class DhmTimeTests(unittest.TestCase):
def test_simple(self):
f = os.fdopen(fd, 'w')
f.write("""one
two
-three\r
+three
for
""")
self.assertEquals(4, len(l))
self.assertEquals("three", l[2])
-
-class StripHtmlTests(unittest.TestCase):
+class SambaWebFileLoadTest(testtools.TestCase):
def test_simple(self):
- self.assertEquals("", util.strip_html("<!--foo-->"))
- self.assertEquals("bar ", util.strip_html("<!--foo-->bar <!--bloe-->"))
- self.assertEquals("bar <bloe>", util.strip_html("<bar>bar <bloe></bar>"))
- self.assertEquals("", util.strip_html("<bar><bloe></bloe></bar>"))
+ fd, name = tempfile.mkstemp()
+ self.addCleanup(os.remove, name)
+ f = os.fdopen(fd, 'w')
+ f.write('href="/samba/index.html"')
+ f.close()
+ l = util.SambaWebFileLoad(os.getcwd(),name)
+ self.assertEquals('href="http://www.samba.org/samba/index.html"', l)
+ fd1, name1 = tempfile.mkstemp()
+ self.addCleanup(os.remove, name1)
+ f1 = os.fdopen(fd1, 'w')
+ f1.write('<!--#include virtual="/samba/name2" -->')
+ f1.close()
+ l1 = util.SambaWebFileLoad(os.path.dirname(os.path.realpath("name1")),name1)
+ self.assertEquals('', l1)
- self.assertEquals("bla", util.strip_html("<a href=\"foo\">bla</a>"))