1 ##############################################################################
2 # Copyright (c) 2017 Tim Rozet (Red Hat)
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from apex.builders import overcloud_builder as oc_builder
13 from apex.common import constants as con
14 from mock import patch
17 class TestOvercloudBuilder(unittest.TestCase):
20 """This method is run once for each class before any tests are run"""
23 def teardown_class(cls):
24 """This method is run once for each class _after_ all tests are run"""
27 """This method is run once before _each_ test method is executed"""
30 """This method is run once after _each_ test method is executed"""
32 @patch('apex.builders.common_builder.create_git_archive')
33 @patch('apex.builders.common_builder.add_repo')
34 @patch('apex.virtual.utils.virt_customize')
35 def test_inject_opendaylight(self, mock_customize, mock_add_repo,
37 mock_git_archive.return_value = '/dummytmp/puppet-opendaylight.tar'
38 archive = '/dummytmp/puppet-opendaylight.tar'
40 {con.VIRT_INSTALL: 'opendaylight'},
41 {con.VIRT_UPLOAD: "{}:/etc/puppet/modules/".format(archive)},
42 {con.VIRT_RUN_CMD: 'rm -rf /etc/puppet/modules/opendaylight'},
43 {con.VIRT_RUN_CMD: "cd /etc/puppet/modules/ && tar xvf "
44 "puppet-opendaylight.tar"}
46 oc_builder.inject_opendaylight(con.DEFAULT_ODL_VERSION, 'dummy.qcow2',
48 assert mock_git_archive.called
49 assert mock_add_repo.called
50 mock_customize.assert_called_once_with(test_virt_ops, 'dummy.qcow2')