Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CastorScript
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
atlas-tdaq-software
CastorScript
Commits
dd1e747c
Commit
dd1e747c
authored
6 years ago
by
Jonas
Browse files
Options
Downloads
Patches
Plain Diff
configparser test, refactor custom conf generation
parent
2836d9f7
No related branches found
No related tags found
1 merge request
!29
Resolve "Initial Publish uptime of CS instance to IS"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Script/UnitTests/ConfigParser_Test.py
+33
-14
33 additions, 14 deletions
Script/UnitTests/ConfigParser_Test.py
with
33 additions
and
14 deletions
Script/UnitTests/ConfigParser_Test.py
+
33
−
14
View file @
dd1e747c
...
@@ -29,12 +29,6 @@ class TestConfigHolder(unittest.TestCase):
...
@@ -29,12 +29,6 @@ class TestConfigHolder(unittest.TestCase):
self
.
assertEquals
(
self
.
templateName
,
cfg
.
FileName
)
self
.
assertEquals
(
self
.
templateName
,
cfg
.
FileName
)
def
test_it_should_save_IS_parameters
(
self
):
def
test_it_should_save_IS_parameters
(
self
):
cfgTemplateFile
=
open
(
self
.
cfgTemplatePath
,
"
r
"
)
# I make a new file
cfgTest
=
open
(
self
.
cfgTest_path
,
"
w
"
)
# And I copy the content and replaces the directories with my own dirs
custom_cfg_lines
=
{
custom_cfg_lines
=
{
"
IS_enabled:
"
:
"
IS_enabled: {}
\n
"
.
format
(
True
),
"
IS_enabled:
"
:
"
IS_enabled: {}
\n
"
.
format
(
True
),
"
IS_partition:
"
:
"
IS_partition:
\'
{}
\'\n
"
.
format
(
"
testPartition
"
),
"
IS_partition:
"
:
"
IS_partition:
\'
{}
\'\n
"
.
format
(
"
testPartition
"
),
...
@@ -42,21 +36,46 @@ class TestConfigHolder(unittest.TestCase):
...
@@ -42,21 +36,46 @@ class TestConfigHolder(unittest.TestCase):
"
IS_publication_period:
"
:
"
IS_publication_period: {}
\n
"
.
format
(
200
),
"
IS_publication_period:
"
:
"
IS_publication_period: {}
\n
"
.
format
(
200
),
}
}
# And I copy the content and replaces the directories with my own dirs
make_custom_config
(
self
.
cfgTemplatePath
,
self
.
cfgTest_path
,
custom_cfg_lines
)
cfg
=
ConfigHolder
(
self
.
cfgTest_path
)
self
.
assertEquals
(
True
,
cfg
.
IS_enabled
)
self
.
assertEquals
(
"
testPartition
"
,
cfg
.
IS_partition
)
self
.
assertEquals
(
"
testServer
"
,
cfg
.
IS_server
)
self
.
assertEquals
(
200
,
cfg
.
IS_publication_period
)
def
test_it_should_save_IS_default_parameters_if_none_configured
(
self
):
custom_cfg_lines
=
{
"
IS_enabled:
"
:
"
\n
"
,
"
IS_partition:
"
:
"
\n
"
,
"
IS_server:
"
:
"
\n
"
,
"
IS_publication_period:
"
:
"
\n
"
,
}
make_custom_config
(
self
.
cfgTemplatePath
,
self
.
cfgTest_path
,
custom_cfg_lines
)
cfg
=
ConfigHolder
(
self
.
cfgTest_path
)
self
.
assertEquals
(
False
,
cfg
.
IS_enabled
)
self
.
assertEquals
(
"
initial
"
,
cfg
.
IS_partition
)
self
.
assertEquals
(
"
RunParams
"
,
cfg
.
IS_server
)
self
.
assertEquals
(
5
,
cfg
.
IS_publication_period
)
def
make_custom_config
(
original_conf_path
,
custom_conf_path
,
modifications
):
cfgTest
=
open
(
custom_conf_path
,
"
w
"
)
cfgTemplateFile
=
open
(
original_conf_path
,
"
r
"
)
# And I copy the content and add my own modifications
for
line
in
cfgTemplateFile
:
for
line
in
cfgTemplateFile
:
for
key
,
value
in
custom_cfg_line
s
.
iteritems
():
for
key
,
value
in
modification
s
.
iteritems
():
if
line
.
find
(
key
)
is
not
-
1
:
if
line
.
find
(
key
)
is
not
-
1
:
line
=
value
line
=
value
cfgTest
.
write
(
line
)
cfgTest
.
write
(
line
)
## close files
cfgTest
.
close
()
cfgTest
.
close
()
cfgTemplateFile
.
close
()
cfgTemplateFile
.
close
()
cfg
=
ConfigHolder
(
self
.
cfgTest_path
)
self
.
assertEquals
(
True
,
cfg
.
IS_enabled
)
self
.
assertEquals
(
"
testPartition
"
,
cfg
.
IS_partition
)
self
.
assertEquals
(
"
testServer
"
,
cfg
.
IS_server
)
self
.
assertEquals
(
200
,
cfg
.
IS_publication_period
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
unittest
.
main
()
...
...
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