Add status tests.
[build-farm.git] / buildfarm / web / tests / test_status.py
1 #!/usr/bin/python
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010
3 #
4 #   This program is free software; you can redistribute it and/or modify
5 #   it under the terms of the GNU General Public License as published by
6 #   the Free Software Foundation; either version 3 of the License, or
7 #   (at your option) any later version.
8 #
9 #   This program is distributed in the hope that it will be useful,
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #   GNU General Public License for more details.
13 #
14 #   You should have received a copy of the GNU General Public License
15 #   along with this program; if not, write to the Free Software
16 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 from buildfarm.data import BuildStatus
19 from buildfarm.web import html_build_status
20
21 import testtools
22
23 class BuildStatusHtmlTests(testtools.TestCase):
24
25     def test_empty(self):
26         status = BuildStatus()
27         self.assertEquals("?", html_build_status(status))
28
29     def test_failed_build(self):
30         status = BuildStatus([("CONFIGURE", 0), ("BUILD", 4)])
31         self.assertEquals(
32             '<span class="status passed">ok</span>/<span class="status failed">4</span>',
33             html_build_status(status))
34
35     def test_disk_full(self):
36         status = BuildStatus([("CONFIGURE", 0), ("BUILD", 4)], set(["timeout"]))
37         self.assertEquals(
38             '<span class="status passed">ok</span>/<span class="status failed">4</span>'
39             '(<span class="status failed">timeout</span>)', html_build_status(status))