Merge "Functest fail to parse refstack results"
[functest.git] / functest / tests / unit / vnf / router / test_cloudify_vrouter.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Okinawa Open Laboratory and others.
4 #
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.0
9
10 # pylint: disable=missing-docstring
11
12 import logging
13 import unittest
14
15 import mock
16
17 from functest.core import vnf
18 from functest.opnfv_tests.vnf.router import cloudify_vrouter
19
20
21 class CloudifyVrouterTesting(unittest.TestCase):
22
23     def setUp(self):
24
25         self.tenant = 'cloudify_vrouter'
26         self.creds = {'username': 'user',
27                       'password': 'pwd'}
28         self.orchestrator = {'name': 'cloudify',
29                              'version': '4.0',
30                              'object': 'foo',
31                              'requirements': {'flavor': {'name': 'm1.medium',
32                                                          'ram_min': 4096},
33                                               'os_image': 'manager_4.0'}}
34
35         self.vnf = {'name': 'vrouter',
36                     'descriptor': {'version': '100',
37                                    'file_name': 'function-test-' +
38                                                 'openstack-blueprint.yaml',
39                                    'name': 'vrouter-opnfv',
40                                    'url': 'https://foo',
41                                    'requirements': {'flavor':
42                                                     {'name': 'm1.medium',
43                                                      'ram_min': 2048}}}}
44
45         # pylint: disable=bad-continuation
46         with mock.patch(
47                 'functest.opnfv_tests.vnf.router.cloudify_vrouter.Utilvnf'), \
48                 mock.patch('functest.opnfv_tests.vnf.router.'
49                            'cloudify_vrouter.vrouter_base.Utilvnf'), \
50                 mock.patch('os.makedirs'), \
51                 mock.patch(
52                     'functest.utils.functest_utils.get_parameter_from_yaml',
53                     return_value={
54                         'tenant_images': 'foo',
55                         'orchestrator': self.orchestrator,
56                         'vnf': self.vnf, 'vnf_test_suite': '',
57                         'version': 'whatever'}):
58
59             self.router_vnf = cloudify_vrouter.CloudifyVrouter()
60
61         self.images = {'image1': 'url1',
62                        'image2': 'url2'}
63         self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
64                         'vnf': {},
65                         'test_vnf':  {}}
66
67     def test_prepare_missing_param(self):
68         with self.assertRaises(vnf.VnfPreparationException):
69             self.router_vnf.prepare()
70
71
72 if __name__ == "__main__":
73     logging.disable(logging.CRITICAL)
74     unittest.main(verbosity=2)