Update Cirros to 0.6.1
[functest.git] / functest / tests / unit / vnf / epc / test_juju_epc.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Rebaca 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 """ Unit test testcase for JuJu EPC Implementation"""
11
12 import logging
13 import unittest
14
15 import mock
16
17 from functest.opnfv_tests.vnf.epc import juju_epc
18
19
20 class JujuEpcTesting(unittest.TestCase):
21     # pylint: disable=missing-docstring
22     """Unittest for ABoT EPC with juju orchestrator"""
23
24     def setUp(self):
25
26         self.tenant = 'juju_epc'
27         self.creds = {'username': 'user',
28                       'password': 'pwd'}
29         self.orchestrator = {'name': 'juju',
30                              'version': '2.0',
31                              'object': 'foo',
32                              'requirements': {'flavor': {'name': 'm1.small',
33                                                          'ram_min': 2048},
34                                               'pip': 'python3-pip',
35                                               'repo_link': 'ppa:juju/stable',
36                                               'dep_package': 'software-'
37                                                              'properties'
38                                                              '-common',
39                                               'pip3_packages': 'juju-wait'}}
40         self.vnf = {'name': 'juju_epc',
41                     'descriptor': {'version': '1',
42                                    'file_name': '/src/epc-test/'
43                                                 'abot_charm/'
44                                                 'functest-abot-'
45                                                 'epc-bundle/bundle.yaml',
46                                    'name': 'abot-oai-epc',
47                                    'requirements': {'flavor':
48                                                     {'name': 'm1.medium',
49                                                      'ram_min': 4096}}}}
50         with mock.patch('functest.opnfv_tests.vnf.epc.juju_epc.os.makedirs'), \
51             mock.patch('functest.opnfv_tests.vnf.epc.juju_epc.get_config',
52                        return_value={'tenant_images': 'foo',
53                                      'orchestrator': self.orchestrator,
54                                      'vnf': self.vnf, 'vnf_test_suite': '',
55                                      'version': 'whatever'}):
56             self.epc_vnf = juju_epc.JujuEpc()
57
58         self.images = {'image1': 'url1',
59                        'image2': 'url2'}
60         self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
61                         'vnf': {},
62                         'test_vnf':  {}}
63
64     @unittest.skip("It must be fixed. Please see JIRA FUNCTEST-915")
65     @mock.patch('os.system')
66     def test_prepare_default(self, *args):
67         """ Unittest for Prepare testcase """
68         self.epc_vnf.orchestrator = self.orchestrator
69         self.assertIsNone(self.epc_vnf.prepare())
70         args[4].assert_called_once_with('test',
71                                         'debayan',
72                                         'OAI EPC deployed '
73                                         'with Juju')
74
75
76 if __name__ == "__main__":
77     logging.disable(logging.CRITICAL)
78     unittest.main(verbosity=2)