diff options
author | 2017-09-20 02:09:28 +0000 | |
---|---|---|
committer | 2017-09-20 02:09:28 +0000 | |
commit | 2045ccff6a31ce649cfabc0ba896e9d0d708e3e0 (patch) | |
tree | 1d24c85739d9193aac7ad03862557d4806f685f4 /tests/unit/prepare/test_prepare_execute.py | |
parent | 64bb1f695fd692dd9e34c4083468c6c053838503 (diff) | |
parent | 861bb6490d9ee9ddf79cdfce7fe677381ea9c945 (diff) |
Merge "Some optimizations about unit test"
Diffstat (limited to 'tests/unit/prepare/test_prepare_execute.py')
-rw-r--r-- | tests/unit/prepare/test_prepare_execute.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/unit/prepare/test_prepare_execute.py b/tests/unit/prepare/test_prepare_execute.py new file mode 100644 index 00000000..03259b93 --- /dev/null +++ b/tests/unit/prepare/test_prepare_execute.py @@ -0,0 +1,67 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import os +import pytest + +import deploy.prepare.execute +from deploy.prepare.execute import ( + _set_qemu_compute, + _set_default_floating_pool, + _set_trusts_auth +) + +deploy.prepare.execute.KOLLA_CONF_PATH = '/tmp' + + +@pytest.fixture(scope="module") +def kolla_conf_file_nova_path(): + return os.path.join(deploy.prepare.execute.KOLLA_CONF_PATH, 'nova') + + +@pytest.fixture(scope="module") +def kolla_conf_file_heat_dir(): + return os.path.join(deploy.prepare.execute.KOLLA_CONF_PATH, 'heat') + + +@pytest.fixture(scope="module") +def conf_file_dir(data_root): + return os.path.join(data_root, 'lab_conf') + + +def clear_tmp_dir(path): + filelist = os.listdir(path) + for file in filelist: + file_path = os.path.join(path, file) + if os.path.isfile(file_path): + os.remove(file_path) + os.rmdir(path) + + +def test__set_qemu_compute(kolla_conf_file_nova_path): + _set_qemu_compute() + exp_conf_file = os.path.join(kolla_conf_file_nova_path, 'nova-compute.conf') + assert os.path.isfile(exp_conf_file) + clear_tmp_dir(kolla_conf_file_nova_path) + + +def test__set_default_floating_pool(kolla_conf_file_nova_path, conf_file_dir): + network_conf_file = os.path.join(conf_file_dir, 'network_virtual1.yml') + _set_default_floating_pool(network_conf_file) + exp_conf_file = os.path.join(kolla_conf_file_nova_path, 'nova-api.conf') + assert os.path.isfile(exp_conf_file) + clear_tmp_dir(kolla_conf_file_nova_path) + + +def test__set_trusts_auth(kolla_conf_file_heat_dir): + _set_trusts_auth() + exp_conf_file_1 = os.path.join(kolla_conf_file_heat_dir, 'heat-api.conf') + exp_conf_file_2 = os.path.join(kolla_conf_file_heat_dir, 'heat-engine.conf') + assert (os.path.isfile(exp_conf_file_1) and os.path.isfile(exp_conf_file_2)) + clear_tmp_dir(kolla_conf_file_heat_dir) |