3 # Copyright (c) 2017 Rebaca and others.
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
10 """ Unit test testcase for JuJu EPC Implementation"""
17 from functest.opnfv_tests.vnf.epc import juju_epc
20 class JujuEpcTesting(unittest.TestCase):
21 # pylint: disable=missing-docstring
22 """Unittest for ABoT EPC with juju orchestrator"""
26 self.tenant = 'juju_epc'
27 self.creds = {'username': 'user',
29 self.orchestrator = {'name': 'juju',
32 'requirements': {'flavor': {'name': 'm1.small',
35 'repo_link': 'ppa:juju/stable',
36 'dep_package': 'software-'
39 'pip3_packages': 'juju-wait'}}
40 self.vnf = {'name': 'juju_epc',
41 'descriptor': {'version': '1',
42 'file_name': '/src/epc-test/'
45 'epc-bundle/bundle.yaml',
46 'name': 'abot-oai-epc',
47 'requirements': {'flavor':
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 mock.patch('functest.utils.openstack_utils.get_keystone_client',
57 return_value='test'), \
58 mock.patch('functest.utils.openstack_utils.get_glance_client',
59 return_value='test'), \
60 mock.patch('functest.utils.openstack_utils.get_neutron_client',
61 return_value='test'), \
62 mock.patch('functest.utils.openstack_utils.get_nova_client',
64 self.epc_vnf = juju_epc.JujuEpc()
66 self.images = {'image1': 'url1',
68 self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
72 @unittest.skip("It must be fixed. Please see JIRA FUNCTEST-915")
73 @mock.patch('functest.utils.openstack_utils.get_keystone_client',
75 @mock.patch('functest.utils.openstack_utils.get_or_create_tenant_for_vnf',
77 @mock.patch('functest.utils.openstack_utils.get_or_create_user_for_vnf',
79 @mock.patch('functest.utils.openstack_utils.get_credentials',
80 return_value={'auth_url': 'test/v1',
81 'project_name': 'test_tenant'})
82 @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
83 @mock.patch('os.system')
84 def test_prepare_default(self, *args):
85 """ Unittest for Prepare testcase """
86 self.epc_vnf.orchestrator = self.orchestrator
87 self.assertIsNone(self.epc_vnf.prepare())
88 args[4].assert_called_once_with('test',
94 if __name__ == "__main__":
95 logging.disable(logging.CRITICAL)
96 unittest.main(verbosity=2)