Adds ability to deploy from upstream openstack
[apex.git] / apex / tests / test_apex_overcloud_builder.py
1 ##############################################################################
2 # Copyright (c) 2017 Tim Rozet (Red Hat)
3 #
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 ##############################################################################
9
10 import unittest
11
12 from apex.builders import overcloud_builder as oc_builder
13 from apex.common import constants as con
14 from mock import patch
15
16
17 class TestOvercloudBuilder(unittest.TestCase):
18     @classmethod
19     def setup_class(cls):
20         """This method is run once for each class before any tests are run"""
21
22     @classmethod
23     def teardown_class(cls):
24         """This method is run once for each class _after_ all tests are run"""
25
26     def setup(self):
27         """This method is run once before _each_ test method is executed"""
28
29     def teardown(self):
30         """This method is run once after _each_ test method is executed"""
31
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,
36                                  mock_git_archive):
37         mock_git_archive.return_value = '/dummytmp/puppet-opendaylight.tar'
38         archive = '/dummytmp/puppet-opendaylight.tar'
39         test_virt_ops = [
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"}
45         ]
46         oc_builder.inject_opendaylight(con.DEFAULT_ODL_VERSION, 'dummy.qcow2',
47                                        '/dummytmp/')
48         assert mock_git_archive.called
49         assert mock_add_repo.called
50         mock_customize.assert_called_once_with(test_virt_ops, 'dummy.qcow2')