summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/jenkins/tests.py
diff options
context:
space:
mode:
authormaxbr <maxbr@mi.fu-berlin.de>2016-08-19 17:10:31 +0200
committermaxbr <maxbr@mi.fu-berlin.de>2016-08-19 17:10:31 +0200
commit3b5ef3b0a88247eeafeee878de528aad71f9fd4b (patch)
tree8f08dcacdfd5b313f04a46406d0282cdde3670e5 /tools/pharos-dashboard/jenkins/tests.py
parente556a63cc5f78598e890346889948765906a6411 (diff)
Split the dashboard into different apps, add tests
JIRA: RELENG-12 Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/jenkins/tests.py')
-rw-r--r--tools/pharos-dashboard/jenkins/tests.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/pharos-dashboard/jenkins/tests.py b/tools/pharos-dashboard/jenkins/tests.py
new file mode 100644
index 00000000..b1414515
--- /dev/null
+++ b/tools/pharos-dashboard/jenkins/tests.py
@@ -0,0 +1,42 @@
+from unittest import TestCase
+
+import jenkins.adapter as jenkins
+
+
+# Tests that the data we get with the jenkinsadapter contains all the
+# data we need. These test will fail if;
+# - there is no internet connection
+# - the opnfv jenkins url has changed
+# - the jenkins api has changed
+# - jenkins is not set up / there is no data
+class JenkinsAdapterTestCase(TestCase):
+ def test_get_all_slaves(self):
+ slaves = jenkins.get_all_slaves()
+ self.assertTrue(len(slaves) > 0)
+ for slave in slaves:
+ self.assertTrue('displayName' in slave)
+ self.assertTrue('idle' in slave)
+ self.assertTrue('offline' in slave)
+
+ def test_get_ci_slaves(self):
+ slaves = jenkins.get_ci_slaves()
+ self.assertTrue(len(slaves) > 0)
+ for slave in slaves:
+ self.assertTrue('nodeName' in slave)
+
+ def test_get_all_jobs(self):
+ jobs = jenkins.get_all_jobs()
+ lastBuild = False
+ self.assertTrue(len(jobs) > 0)
+ for job in jobs:
+ self.assertTrue('displayName' in job)
+ self.assertTrue('url' in job)
+ self.assertTrue('lastBuild' in job)
+ if job['lastBuild'] is not None:
+ lastBuild = True
+ self.assertTrue('building' in job['lastBuild'])
+ self.assertTrue('fullDisplayName' in job['lastBuild'])
+ self.assertTrue('result' in job['lastBuild'])
+ self.assertTrue('timestamp' in job['lastBuild'])
+ self.assertTrue('builtOn' in job['lastBuild'])
+ self.assertTrue(lastBuild)