Add hostdb.host() test.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 15 Nov 2010 01:11:04 +0000 (02:11 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 15 Nov 2010 01:11:04 +0000 (02:11 +0100)
Improve unicode handling in web ui.

buildfarm/tests/test_hostdb.py
web/build.py

index f50c568ab9ce18ef829f680ba1db9b8a91656457..ca406f4cdd81b63297eb418dda501592ab8f1f5f 100644 (file)
@@ -41,6 +41,11 @@ class HostDatabaseTests(object):
         self.assertEquals(1, len(hosts))
         self.assertEquals("charis", hosts[0].name)
 
+    def test_host(self):
+        newhost = self.db.createhost(u"charis", u"linux", u"Jelmer", u"jelmer@samba.org", u"bla", u"Pemrission?")
+        samehost = self.db.host(u"charis")
+        self.assertEquals(samehost, newhost)
+
     def test_create_already_exists(self):
         host = self.db.createhost(name=u"foo", owner=u"Jelmer", owner_email=u"jelmer@samba.org")
         self.assertRaises(hostdb.HostAlreadyExists,  self.db.createhost, name=u"foo",
index d4edffececa21ee1dc22402443a27ce3b6733fec..d2b3bd0061ed6506ff379c5ca3c7ef836b76d8bb 100755 (executable)
@@ -466,7 +466,7 @@ class ViewBuildPage(BuildFarmPage):
 
     def show_oldrevs(self, myself, tree, host, compiler):
         """show the available old revisions, if any"""
-        old_rev_builds  = self.buildfarm.builds.get_old_revs(tree, host, compiler)
+        old_rev_builds  = self.buildfarm.builds.get_old_revs(tree.decode('utf-8'), host.decode('utf-8'), compiler.decode('utf-8'))
 
         if len(old_rev_builds) == 0:
             return
@@ -485,17 +485,12 @@ class ViewBuildPage(BuildFarmPage):
 
         yield "</tbody></table>"
 
-    def render(self, myself, tree, host, compiler, rev, plain_logs=False):
+    def render(self, myself, tree, hostname, compiler, rev, plain_logs=False):
         """view one build in detail"""
-        # ensure the params are valid before using them
-        self.buildfarm.hostdb.host(host)
-        assert compiler in self.buildfarm.compilers, "unknown compiler %s" % compiler
-        assert tree in self.buildfarm.trees, "not a build tree %s" % tree
-
         uname = ""
         cflags = ""
         config = ""
-        build = buildfarm.get_build(tree, host, compiler, rev)
+        build = buildfarm.get_build(tree, hostname, compiler, rev)
         age_mtime = build.age_mtime()
         try:
             (revision, revision_time) = build.revision_details()
@@ -535,14 +530,14 @@ class ViewBuildPage(BuildFarmPage):
             err = cgi.escape(err)
         yield '<h2>Host information:</h2>'
 
-        host_web_file = "../web/%s.html" % host
+        host_web_file = "../web/%s.html" % hostname
         if os.path.exists(host_web_file):
             yield util.FileLoad(host_web_file)
 
         yield "<table class='real'>\n"
         yield "<tr><td>Host:</td><td><a href='%s?function=View+Host;host=%s;tree=%s;"\
               "compiler=%s#'>%s</a> - %s</td></tr>\n" %\
-                (myself, host, tree, compiler, host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
+                (myself, hostname, tree, compiler, hostname, host.platform.encode("utf-8"))
         yield "<tr><td>Uname:</td><td>%s</td></tr>\n" % uname
         yield "<tr><td>Tree:</td><td>%s</td></tr>\n" % self.tree_link(myself, tree)
         yield "<tr><td>Build Revision:</td><td>%s</td></tr>\n" % revision_link(myself, revision, tree)
@@ -553,7 +548,7 @@ class ViewBuildPage(BuildFarmPage):
         yield "<tr><td>configure options:</td><td>%s</td></tr>\n" % config
         yield "</table>\n"
 
-        yield "".join(self.show_oldrevs(myself, tree, host, compiler))
+        yield "".join(self.show_oldrevs(myself, tree, hostname, compiler))
 
         # check the head of the output for our magic string
         rev_var = ""
@@ -565,7 +560,7 @@ class ViewBuildPage(BuildFarmPage):
         if not plain_logs:
             yield "<p>Switch to the <a href='%s?function=View+Build;host=%s;tree=%s"\
                   ";compiler=%s%s;plain=true' title='Switch to bland, non-javascript,"\
-                  " unstyled view'>Plain View</a></p>" % (myself, host, tree, compiler, rev_var)
+                  " unstyled view'>Plain View</a></p>" % (myself, hostname, tree, compiler, rev_var)
 
             yield "<div id='actionList'>"
             # These can be pretty wide -- perhaps we need to
@@ -587,7 +582,7 @@ class ViewBuildPage(BuildFarmPage):
         else:
             yield "<p>Switch to the <a href='%s?function=View+Build;host=%s;tree=%s;"\
                   "compiler=%s%s' title='Switch to colourful, javascript-enabled, styled"\
-                  " view'>Enhanced View</a></p>" % (myself, host, tree, compiler, rev_var)
+                  " view'>Enhanced View</a></p>" % (myself, hostname, tree, compiler, rev_var)
             if err == "":
                 yield "<h2>No error log available</h2>"
             else: