3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
13 from functest.opnfv_tests.vnf.ims import clearwater
14 from functest.opnfv_tests.vnf.ims import orchestrator_cloudify
17 class ClearwaterTesting(unittest.TestCase):
19 logging.disable(logging.CRITICAL)
22 self.clearwater = clearwater.Clearwater()
23 self.orchestrator = orchestrator_cloudify.Orchestrator('test_dir')
24 self.clearwater.orchestrator = self.orchestrator
25 self.clearwater.dep_name = 'test_dep_name'
26 self.bp = {'file_name': 'test_file',
27 'destination_folder': 'test_folder',
29 'branch': 'test_branch'}
31 def test_deploy_vnf_blueprint_download_failed(self):
32 with mock.patch.object(self.clearwater.orchestrator,
33 'download_upload_and_deploy_blueprint',
34 return_value='error'):
35 self.assertEqual(self.clearwater.deploy_vnf(self.bp),
38 def test_deploy_vnf_blueprint_download_passed(self):
39 with mock.patch.object(self.clearwater.orchestrator,
40 'download_upload_and_deploy_blueprint',
42 self.clearwater.deploy_vnf(self.bp)
43 self.assertEqual(self.clearwater.deploy, True)
45 def test_undeploy_vnf_deployment_passed(self):
46 with mock.patch.object(self.clearwater.orchestrator,
47 'undeploy_deployment'):
48 self.clearwater.deploy = True
49 self.clearwater.undeploy_vnf()
50 self.assertEqual(self.clearwater.deploy, False)
52 def test_undeploy_vnf_deployment_with_undeploy(self):
53 with mock.patch.object(self.clearwater.orchestrator,
54 'undeploy_deployment') as m:
55 self.clearwater.deploy = False
56 self.clearwater.undeploy_vnf(),
57 self.assertEqual(self.clearwater.deploy, False)
58 self.assertFalse(m.called)
60 self.clearwater.orchestrator = None
61 self.clearwater.deploy = True
62 self.clearwater.undeploy_vnf(),
63 self.assertEqual(self.clearwater.deploy, True)
65 self.clearwater.deploy = False
66 self.clearwater.undeploy_vnf(),
67 self.assertEqual(self.clearwater.deploy, False)
69 def test_set_methods(self):
70 self.clearwater.set_orchestrator(self.orchestrator)
71 self.assertTrue(self.clearwater.orchestrator, self.orchestrator)
72 self.clearwater.set_flavor_id('test_flavor_id')
73 self.assertTrue(self.clearwater.config['flavor_id'], 'test_flavor_id')
74 self.clearwater.set_image_id('test_image_id')
75 self.assertTrue(self.clearwater.config['image_id'], 'test_image_id')
76 self.clearwater.set_agent_user('test_user')
77 self.assertTrue(self.clearwater.config['agent_user'], 'test_user')
78 self.clearwater.set_external_network_name('test_network')
79 self.assertTrue(self.clearwater.config['external_network_name'],
81 self.clearwater.set_public_domain('test_domain')
82 self.assertTrue(self.clearwater.config['public_domain'],
85 if __name__ == "__main__":
86 unittest.main(verbosity=2)