Unit tests for vnf/ims.
[functest.git] / functest / tests / unit / opnfv_tests / vnf / ims / test_clearwater.py
1 #!/usr/bin/env python
2
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
7
8 import logging
9 import unittest
10
11 import mock
12
13 from functest.opnfv_tests.vnf.ims import clearwater
14 from functest.opnfv_tests.vnf.ims import orchestrator_cloudify
15
16
17 class ClearwaterTesting(unittest.TestCase):
18
19     logging.disable(logging.CRITICAL)
20
21     def setUp(self):
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',
28                    'url': 'test_url',
29                    'branch': 'test_branch'}
30
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),
36                              'error')
37
38     def test_deploy_vnf_blueprint_download_passed(self):
39         with mock.patch.object(self.clearwater.orchestrator,
40                                'download_upload_and_deploy_blueprint',
41                                return_value=''):
42             self.clearwater.deploy_vnf(self.bp),
43             self.assertEqual(self.clearwater.deploy, True)
44
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)
51
52
53 if __name__ == "__main__":
54     unittest.main(verbosity=2)