Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-pylib
Commits
6d799ab2
Unverified
Commit
6d799ab2
authored
6 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: add tests for envvar configuration
parent
b1344dd4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caosdb/configuration.py
+5
-1
5 additions, 1 deletion
src/caosdb/configuration.py
unittests/test_add_property.py
+0
-5
0 additions, 5 deletions
unittests/test_add_property.py
unittests/test_configuration.py
+39
-0
39 additions, 0 deletions
unittests/test_configuration.py
with
44 additions
and
6 deletions
src/caosdb/configuration.py
+
5
−
1
View file @
6d799ab2
...
@@ -35,12 +35,16 @@ def _reset_config():
...
@@ -35,12 +35,16 @@ def _reset_config():
def
configure
(
inifile
):
def
configure
(
inifile
):
"""
read config from file.
Return a list of files which have successfully been parsed.
"""
global
_pycaosdbconf
global
_pycaosdbconf
if
"
_pycaosdbconf
"
not
in
globals
():
if
"
_pycaosdbconf
"
not
in
globals
():
_pycaosdbconf
=
None
_pycaosdbconf
=
None
if
_pycaosdbconf
is
None
:
if
_pycaosdbconf
is
None
:
_reset_config
()
_reset_config
()
_pycaosdbconf
.
read
(
inifile
)
return
_pycaosdbconf
.
read
(
inifile
)
def
get_config
():
def
get_config
():
...
...
This diff is collapsed.
Click to expand it.
unittests/test_add_property.py
+
0
−
5
View file @
6d799ab2
...
@@ -21,12 +21,7 @@
...
@@ -21,12 +21,7 @@
#
#
# ** end header
# ** end header
#
#
"""
Created on 19.06.2017.
@author: tf
"""
import
caosdb
as
db
import
caosdb
as
db
# @UnresolvedImport
from
nose.tools
import
assert_is
,
assert_is_none
,
assert_equals
,
assert_is_not_none
,
assert_raises
from
nose.tools
import
assert_is
,
assert_is_none
,
assert_equals
,
assert_is_not_none
,
assert_raises
...
...
This diff is collapsed.
Click to expand it.
unittests/test_configuration.py
0 → 100644
+
39
−
0
View file @
6d799ab2
# -*- encoding: utf-8 -*-
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
#
import
caosdb
as
db
from
pytest
import
raises
def
test_config_ini_via_envvar
():
from
os
import
environ
from
os.path
import
expanduser
with
raises
(
KeyError
):
environ
[
"
PYCAOSDBINI
"
]
environ
[
"
PYCAOSDBINI
"
]
=
"
bla bla
"
assert
environ
[
"
PYCAOSDBINI
"
]
==
"
bla bla
"
assert
db
.
configuration
.
configure
(
environ
[
"
PYCAOSDBINI
"
])
==
[]
environ
[
"
PYCAOSDBINI
"
]
=
"
~/.pycaosdb.ini
"
assert
db
.
configuration
.
configure
(
expanduser
(
environ
[
"
PYCAOSDBINI
"
]))
==
[
expanduser
(
"
~/.pycaosdb.ini
"
)]
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