Update unit test related to vyos_vrouter
[functest-xtesting.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 import logging
11 import unittest
12
13 import mock
14
15 from functest.core import vnf
16 from functest.opnfv_tests.vnf.router import cloudify_vrouter
17
18
19 class CloudifyVrouterTesting(unittest.TestCase):
20
21     @mock.patch('functest.opnfv_tests.vnf.router.cloudify_vrouter.Utilvnf')
22     @mock.patch('functest.opnfv_tests.vnf.router.cloudify_vrouter.vrouter_base'
23                 '.Utilvnf')
24     @mock.patch('os.makedirs')
25     def setUp(self, *args):
26
27         self.tenant = 'cloudify_vrouter'
28         self.creds = {'username': 'user',
29                       'password': 'pwd'}
30         self.orchestrator = {'name': 'cloudify',
31                              'version': '4.0',
32                              'object': 'foo',
33                              'requirements': {'flavor': {'name': 'm1.medium',
34                                                          'ram_min': 4096},
35                                               'os_image': 'manager_4.0'}}
36
37         self.vnf = {'name': 'vrouter',
38                     'descriptor': {'version': '100',
39                                    'file_name': 'function-test-' +
40                                                 'openstack-blueprint.yaml',
41                                    'name': 'vrouter-opnfv',
42                                    'url': 'https://foo',
43                                    'requirements': {'flavor':
44                                                     {'name': 'm1.medium',
45                                                      'ram_min': 2048}}}}
46
47         with mock.patch('functest.opnfv_tests.vnf.router.cloudify_vrouter.'
48                         'get_config', return_value={
49                             'tenant_images': 'foo',
50                             'orchestrator': self.orchestrator,
51                             'vnf': self.vnf,
52                             'vnf_test_suite': '',
53                             'version': 'whatever'}):
54
55             self.router_vnf = cloudify_vrouter.CloudifyVrouter()
56
57         self.images = {'image1': 'url1',
58                        'image2': 'url2'}
59         self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
60                         'vnf': {},
61                         'test_vnf':  {}}
62
63     def test_prepare_missing_param(self):
64         with self.assertRaises(vnf.VnfPreparationException):
65             self.router_vnf.prepare()
66
67
68 if __name__ == "__main__":
69     logging.disable(logging.CRITICAL)
70     unittest.main(verbosity=2)