Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
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
simulation
KM3BUU
Commits
bd1848d5
Commit
bd1848d5
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Update config and introduce config tests
parent
0f2ee957
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
KM3NeT Dataformat data writeout
Pipeline
#16370
passed with warnings
4 years ago
Stage: test
Stage: coverage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3buu/config.py
+4
-3
4 additions, 3 deletions
km3buu/config.py
km3buu/tests/test_config.py
+56
-0
56 additions, 0 deletions
km3buu/tests/test_config.py
with
60 additions
and
3 deletions
km3buu/config.py
+
4
−
3
View file @
bd1848d5
...
...
@@ -37,7 +37,7 @@ GIBUU_IMAGE_PATH_KEY = "image_path"
PROPOSAL_SECTION
=
"
PROPOSAL
"
PROPOSAL_ITP_PATH_KEY
=
"
itp_table_path
"
GSEAGEN_SECTION
=
"
gSea
g
en
"
GSEAGEN_SECTION
=
"
gSea
G
en
"
GSEAGEN_PATH_KEY
=
"
path
"
GSEAGEN_MEDIA_COMPOSITION_FILE
=
"
MediaComposition.xml
"
...
...
@@ -71,6 +71,7 @@ class Config(object):
@property
def
gibuu_image_path
(
self
):
key
=
GIBUU_IMAGE_PATH_KEY
image_path
=
self
.
get
(
GIBUU_SECTION
,
GIBUU_IMAGE_PATH_KEY
)
if
image_path
is
None
or
not
isfile
(
image_path
):
dev_path
=
abspath
(
join
(
dirname
(
__file__
),
os
.
pardir
,
IMAGE_NAME
))
...
...
@@ -117,11 +118,11 @@ class Config(object):
@property
def
km3net_lib_path
(
self
):
return
self
.
s
et
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
None
)
return
self
.
g
et
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
None
)
@km3net_lib_path.setter
def
km3net_lib_path
(
self
,
value
):
return
self
.
g
et
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
value
)
self
.
s
et
(
GENERAL_SECTION
,
KM3NET_LIB_PATH_KEY
,
value
)
def
read_media_compositions
(
filename
):
...
...
This diff is collapsed.
Click to expand it.
km3buu/tests/test_config.py
0 → 100644
+
56
−
0
View file @
bd1848d5
#!/usr/bin/env python
# coding=utf-8
# Filename: test_ctrl.py
__author__
=
"
Johannes Schumann
"
__copyright__
=
"
Copyright 2020, Johannes Schumann and the KM3NeT collaboration.
"
__credits__
=
[]
__license__
=
"
MIT
"
__maintainer__
=
"
Johannes Schumann
"
__email__
=
"
jschumann@km3net.de
"
__status__
=
"
Development
"
import
os
import
unittest
from
unittest.mock
import
patch
import
numpy
as
np
from
km3buu.jobcard
import
*
from
km3buu.config
import
Config
,
read_media_compositions
from
tempfile
import
NamedTemporaryFile
TEST_CONFIG
=
"""
[General]
km3net_lib_path=/tmp/km3net_lib_test
[GiBUU]
image_path=%s
[PROPOSAL]
itp_table_path=/tmp/.tables
[gSeaGen]
path=/tmp/gseagen
"""
class
TestConfig
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
cfg_tmpfile
=
NamedTemporaryFile
(
delete
=
False
)
self
.
mock_image_file
=
NamedTemporaryFile
(
delete
=
False
)
with
open
(
self
.
cfg_tmpfile
.
name
,
"
w
"
)
as
f
:
f
.
write
(
TEST_CONFIG
%
self
.
mock_image_file
.
name
)
self
.
cfg
=
Config
(
self
.
cfg_tmpfile
.
name
)
def
tearDown
(
self
):
os
.
remove
(
self
.
cfg_tmpfile
.
name
)
os
.
remove
(
self
.
mock_image_file
.
name
)
def
test_general_section
(
self
):
assert
self
.
cfg
.
km3net_lib_path
==
"
/tmp/km3net_lib_test
"
def
test_gibuu_section
(
self
):
assert
self
.
cfg
.
gibuu_image_path
==
self
.
mock_image_file
.
name
def
test_proposal_section
(
self
):
assert
self
.
cfg
.
proposal_itp_tables
==
"
/tmp/.tables
"
def
test_gseagen_path
(
self
):
assert
self
.
cfg
.
gseagen_path
==
"
/tmp/gseagen
"
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