3 # Copyright (c) 2016 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0import requests
12 from opnfv.utils import OPNFVExceptions
16 raise OPNFVExceptions.TestDbNotReachable('Test database is not reachable')
19 def base_function_wrong():
20 raise OPNFVExceptions.NotSelfDefinedException
23 def db_connectivity():
24 url = 'http://testresults.opnfv2.org/test/api/v1/projects/functest/cases'
26 if r.status_code is not 200:
27 raise OPNFVExceptions.TestDbNotReachable('Database not found')
30 def project_unknown():
31 url = 'http://testresults.opnfv.org/test/api/v1/projects/functest2/cases'
33 if len(r.json()['testcases']) is 0:
34 raise OPNFVExceptions.UnknownProject
37 class TestBasicRaise(unittest.TestCase):
39 with self.assertRaises(Exception) as context:
41 self.assertTrue('Test database is not reachable' in context.exception)
44 class TestWrongRaise(unittest.TestCase):
48 except OPNFVExceptions.OPNFVException:
50 except AttributeError:
54 class TestCaseDBNotReachable(unittest.TestCase):
56 with self.assertRaises(Exception) as context:
58 self.assertTrue('Database not found' in context.exception)
61 class TestUnkownProject(unittest.TestCase):
65 except OPNFVExceptions.TestDashboardError:
68 except OPNFVExceptions.UnknownProject:
73 if __name__ == '__main__':