diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-11-10 16:08:04 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-11-10 16:08:04 +0000 |
| commit | 28cccf51844f60ff5dc845f4a2c4d44762284b3e (patch) | |
| tree | 7c341d7ac1803af1fa784d15b8523a30bac25f1d | |
| parent | 15290dc6cc1d865de54b402c7bc8677f290d7c61 (diff) | |
| parent | 1af722eb494d1173bfcc9aec1cdb8aab93cf6fc8 (diff) | |
| download | kolla-28cccf51844f60ff5dc845f4a2c4d44762284b3e.tar.gz kolla-28cccf51844f60ff5dc845f4a2c4d44762284b3e.zip | |
Merge "Add a test case for load_config"
| -rw-r--r-- | tests/test_set_config.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_set_config.py b/tests/test_set_config.py new file mode 100644 index 000000000..c1e7f7927 --- /dev/null +++ b/tests/test_set_config.py @@ -0,0 +1,47 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import imp +import json +import mock +import os.path +import sys + +from oslotest import base + +# nasty: to import set_config (not a part of the kolla package) +this_dir = os.path.dirname(sys.modules[__name__].__file__) +set_configs_file = os.path.abspath( + os.path.join(this_dir, '..', + 'docker', 'base', 'set_configs.py')) + +set_configs = imp.load_source('set_configs', set_configs_file) + + +class LoadFromFile(base.BaseTestCase): + + def test_load_ok(self): + in_config = json.dumps({'command': '/bin/true', + 'config_files': {}}) + + mo = mock.mock_open(read_data=in_config) + with mock.patch.object(set_configs, 'open', mo): + set_configs.load_config() + self.assertEqual([ + mock.call('/var/lib/kolla/config_files/config.json'), + mock.call().__enter__(), + mock.call().read(), + mock.call().__exit__(None, None, None), + mock.call('/run_command', 'w+'), + mock.call().__enter__(), + mock.call().write(u'/bin/true'), + mock.call().__exit__(None, None, None)], mo.mock_calls) |
