Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kolla Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Very Demiurge Very Mindful
Kolla Ansible
Commits
28cccf51
Commit
28cccf51
authored
9 years ago
by
Jenkins
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add a test case for load_config"
parents
15290dc6
1af722eb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_set_config.py
+47
-0
47 additions, 0 deletions
tests/test_set_config.py
with
47 additions
and
0 deletions
tests/test_set_config.py
0 → 100644
+
47
−
0
View file @
28cccf51
# 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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment