summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/jenkins/tests.py
blob: b1414515cef9fb84c6ce2d8d969b1bc8af323af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)