diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2016-05-25 09:50:08 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-05-25 09:50:08 +0000 |
commit | f41cc29366b2660ef7d9cb85be6b04b737526f45 (patch) | |
tree | b236264b26a1a037c59635227b5cce9fcd0f00e3 /utils/test/result_collection_api/tests/unit/test_dashboard.py | |
parent | 345abdddd5d263b53e3104c1cb9f657515521f77 (diff) | |
parent | f4f8328db358131963b3fa9e81677bf570b8d0aa (diff) |
Merge "add test result/dashboard related unittests in testAPI and refactor its response"
Diffstat (limited to 'utils/test/result_collection_api/tests/unit/test_dashboard.py')
-rw-r--r-- | utils/test/result_collection_api/tests/unit/test_dashboard.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/utils/test/result_collection_api/tests/unit/test_dashboard.py b/utils/test/result_collection_api/tests/unit/test_dashboard.py new file mode 100644 index 000000000..1e0d22b91 --- /dev/null +++ b/utils/test/result_collection_api/tests/unit/test_dashboard.py @@ -0,0 +1,71 @@ +import unittest + +from test_result import TestResultBase +from common.constants import HTTP_NOT_FOUND, HTTP_OK + +__author__ = '__serena__' + + +class TestDashboardBase(TestResultBase): + def setUp(self): + super(TestDashboardBase, self).setUp() + self.basePath = '/dashboard' + self.create_help('/results', self.req_d) + self.create_help('/results', self.req_d) + self.list_res = None + + +class TestDashboardQuery(TestDashboardBase): + def test_projectMissing(self): + code, body = self.query(self._set_query(project='missing')) + self.assertEqual(code, HTTP_NOT_FOUND) + self.assertIn('Project name missing', body) + + def test_projectNotReady(self): + code, body = self.query(self._set_query(project='notReadyProject')) + self.assertEqual(code, HTTP_NOT_FOUND) + self.assertIn('Project [notReadyProject] not dashboard ready', body) + + def test_testcaseMissing(self): + code, body = self.query(self._set_query(case='missing')) + self.assertEqual(code, HTTP_NOT_FOUND) + self.assertIn('Test case missing for project [{}]' + .format(self.project), + body) + + def test_testcaseNotReady(self): + code, body = self.query(self._set_query(case='notReadyCase')) + self.assertEqual(code, HTTP_NOT_FOUND) + self.assertIn( + 'Test case [notReadyCase] not dashboard ready for project [%s]' + % self.project, + body) + + def test_success(self): + code, body = self.query(self._set_query()) + self.assertEqual(code, HTTP_OK) + self.assertIn('{"description": "vPing results for Dashboard"}', body) + + def test_caseIsStatus(self): + code, body = self.query(self._set_query(case='status')) + self.assertEqual(code, HTTP_OK) + self.assertIn('{"description": "Functest status"}', body) + + def _set_query(self, project=None, case=None): + uri = '' + for k, v in list(locals().iteritems()): + if k == 'self' or k == 'uri': + continue + if v is None: + v = eval('self.' + k) + if v != 'missing': + uri += '{}={}&'.format(k, v) + uri += 'pod={}&'.format(self.pod) + uri += 'version={}&'.format(self.version) + uri += 'installer={}&'.format(self.installer) + uri += 'period={}&'.format(5) + return uri[0:-1] + + +if __name__ == '__main__': + unittest.main() |