3 from test_result import TestResultBase
4 from opnfv_testapi.common.constants import HTTP_NOT_FOUND, HTTP_OK
6 __author__ = '__serena__'
9 class TestDashboardBase(TestResultBase):
11 super(TestDashboardBase, self).setUp()
12 self.basePath = '/dashboard/v1/results'
13 self.create_help('/api/v1/results', self.req_d)
14 self.create_help('/api/v1/results', self.req_d)
18 class TestDashboardQuery(TestDashboardBase):
19 def test_projectMissing(self):
20 code, body = self.query(self._set_query(project='missing'))
21 self.assertEqual(code, HTTP_NOT_FOUND)
22 self.assertIn('Project name missing', body)
24 def test_projectNotReady(self):
25 code, body = self.query(self._set_query(project='notReadyProject'))
26 self.assertEqual(code, HTTP_NOT_FOUND)
27 self.assertIn('Project [notReadyProject] not dashboard ready', body)
29 def test_testcaseMissing(self):
30 code, body = self.query(self._set_query(case='missing'))
31 self.assertEqual(code, HTTP_NOT_FOUND)
32 self.assertIn('Test case missing for project [{}]'
33 .format(self.project),
36 def test_testcaseNotReady(self):
37 code, body = self.query(self._set_query(case='notReadyCase'))
38 self.assertEqual(code, HTTP_NOT_FOUND)
40 'Test case [notReadyCase] not dashboard ready for project [%s]'
44 def test_success(self):
45 code, body = self.query(self._set_query())
46 self.assertEqual(code, HTTP_OK)
47 self.assertIn('{"description": "vPing results for Dashboard"}', body)
49 def test_caseIsStatus(self):
50 code, body = self.query(self._set_query(case='status'))
51 self.assertEqual(code, HTTP_OK)
52 self.assertIn('{"description": "Functest status"}', body)
54 def _set_query(self, project=None, case=None):
56 for k, v in list(locals().iteritems()):
57 if k == 'self' or k == 'uri':
62 uri += '{}={}&'.format(k, v)
63 uri += 'pod={}&'.format(self.pod)
64 uri += 'version={}&'.format(self.version)
65 uri += 'installer={}&'.format(self.installer)
66 uri += 'period={}&'.format(5)
70 if __name__ == '__main__':