Merge "Remove get_repo_tag"
[functest.git] / functest / tests / unit / vnf / ims / test_orchestra_clearwaterims.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 """Test module for orchestra_clearwaterims"""
9
10 import logging
11 import unittest
12
13 import mock
14
15 from functest.core import vnf
16 from functest.opnfv_tests.vnf.ims import orchestra_clearwaterims
17
18
19 class OrchestraClearwaterImsTesting(unittest.TestCase):
20     """Test class for orchestra_clearwaterims"""
21     def setUp(self):
22
23         self.tenant = 'orchestra_clearwaterims'
24         self.creds = {'username': 'mocked_username',
25                       'password': 'mocked_password'}
26         self.tenant_images = {
27             'image1': 'mocked_image_url_1',
28             'image2': 'mocked_image_url_2'
29         }
30         self.mano = {
31             'name': 'openbaton',
32             'version': '3.2.0',
33             'object': 'foo',
34             'requirements': {
35                 'flavor': {
36                     'name': 'mocked_flavor',
37                     'ram_min': 4096,
38                     'disk': 5,
39                     'vcpus': 2
40                 },
41                 'os_image': 'mocked_image'
42             },
43             'bootstrap': {
44                 'url': 'mocked_bootstrap_url',
45                 'config': {
46                     'url': 'mocked_config_url'}
47             },
48             'gvnfm': {
49                 'userdata': {
50                     'url': 'mocked_userdata_url'
51                 }
52             },
53             'credentials': {
54                 'username': 'mocked_username',
55                 'password': 'mocked_password'
56             }
57         }
58         self.vnf = {
59             'name': 'openims',
60             'descriptor': {
61                 'url': 'mocked_descriptor_url'
62             },
63             'requirements': {
64                 'flavor': {
65                     'name': 'mocked_flavor',
66                     'ram_min': 2048,
67                     'disk': 5,
68                     'vcpus': 2}
69             }
70         }
71         self.clearwaterims = {
72             'scscf': {
73                 'ports': [3870, 6060]
74             },
75             'pcscf': {
76                 'ports': [4060]
77             },
78             'icscf': {
79                 'ports': [3869, 5060]
80             },
81             'fhoss': {
82                 'ports': [3868]
83             },
84             'bind9': {
85                 'ports': []
86             }
87         }
88         with mock.patch('functest.opnfv_tests.vnf.ims.orchestra_clearwaterims.'
89                         'os.makedirs'),\
90             mock.patch('functest.opnfv_tests.vnf.ims.orchestra_clearwaterims.'
91                        'get_config', return_value={
92                            'orchestrator': self.mano,
93                            'name': self.mano['name'],
94                            'version': self.mano['version'],
95                            'requirements': self.mano['requirements'],
96                            'credentials': self.mano['credentials'],
97                            'bootstrap': self.mano['bootstrap'],
98                            'gvnfm': self.mano['gvnfm'],
99                            'os_image': self.mano['requirements']['os_image'],
100                            'flavor': self.mano['requirements']['flavor'],
101                            'url': self.mano['bootstrap']['url'],
102                            'config': self.mano['bootstrap']['config'],
103                            'tenant_images': self.tenant_images,
104                            'vnf': self.vnf,
105                            'orchestra_clearwaterims': self.clearwaterims}):
106             self.ims_vnf = orchestra_clearwaterims.ClearwaterImsVnf()
107
108         self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
109                         'vnf': {},
110                         'test_vnf': {}}
111
112     def test_prepare_missing_param(self):
113         """Testing prepare function with missing param"""
114         with self.assertRaises(vnf.VnfPreparationException):
115             self.ims_vnf.prepare()
116
117
118 if __name__ == "__main__":
119     logging.disable(logging.CRITICAL)
120     unittest.main(verbosity=2)