diff --git a/pytest.ini b/pytest.ini index abdd410e5f9e9835a3233b22687ad49cc1109235..ca6aad829a3e0607292cf69b8b1d4b7f7758993e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] -testpaths = unittests -addopts = -vv --cov=caosdb +testpaths=unittests +addopts=-x -vv --cov=caosdb diff --git a/setup.cfg b/setup.cfg index 74c5620b86c6fd5ee96abea95dab4010c9fb87a3..c46089e4d24843d7d4cc4f83dad6ec1351e4cc3f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,4 @@ +[aliases] +test=pytest [pycodestyle] ignore=E501,E121,E123,E126,E226,E24,E704,W503,W504 diff --git a/setup.py b/setup.py index c0ca6bbbae810642ec47a2ea2781a134baa75207..bf55edfea07b1864eb67ff48a68986df639cc4de 100755 --- a/setup.py +++ b/setup.py @@ -35,5 +35,6 @@ setup(name='PyCaosDB', install_requires=['lxml>=3.6.4', 'PyYaml>=3.12', 'future'], extras_require={'keyring': ['keyring>=13.0.0']}, + setup_requires=["pytest-runner>=2.0,<3dev"], tests_require=["pytest", "pytest-cov", "coverage>=4.4.2"], ) diff --git a/src/caosdb/common/administration.py b/src/caosdb/common/administration.py index eff03f8d97b889ea9d934c2edb4d9ba2fe50da9d..e5a817b7f830a80cc48441a15a5b05a047af7503 100644 --- a/src/caosdb/common/administration.py +++ b/src/caosdb/common/administration.py @@ -53,6 +53,7 @@ def set_server_property(key, value): con._form_data_request(method="POST", path="_server_properties", params={key: value}).read() + def get_server_properties(): """get_server_properties @@ -71,6 +72,7 @@ def get_server_properties(): props[elem.tag] = elem.text return props + def get_server_property(key): """get_server_property diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index e07f97134035b79b66f1bfb9c33ee3b6d33ac97d..71c5c2b633222f3050944aecf212ea82979fda5a 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -1822,11 +1822,13 @@ class Container(list): insertion, update, and deletion which are a applied to all entities in the container or the whole container respectively. """ + _debug = staticmethod( lambda: ( get_config().getint( "Container", - "debug") if get_config().get( + "debug") if get_config().has_section("Container") and + get_config().get( "Container", "debug") is not None else 0)) diff --git a/src/caosdb/configuration.py b/src/caosdb/configuration.py index c8895f90dde1a4a8076b5cc47d3fc265863a41ec..3933845c448da8d6164447aeec76b3aa2c65a929 100644 --- a/src/caosdb/configuration.py +++ b/src/caosdb/configuration.py @@ -28,6 +28,7 @@ except ImportError: # python3 from configparser import ConfigParser + def _reset_config(): global _pycaosdbconf _pycaosdbconf = ConfigParser(allow_no_value=False) diff --git a/src/caosdb/connection/connection.py b/src/caosdb/connection/connection.py index eceaff0bbf7d2c54ed059e46c6d0eafb61107f9d..90e6f40199228cc037640af76f58ca4506ebb88b 100644 --- a/src/caosdb/connection/connection.py +++ b/src/caosdb/connection/connection.py @@ -79,6 +79,7 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection): configure request """ + def __init__(self): self._useragent = ("PyCaosDB - " "DefaultCaosDBServerConnection") @@ -233,8 +234,8 @@ def _get_authenticator(**config): except ImportError: raise ConfigurationException("Password method \"{}\" not implemented. " - "Valid methods: plain, pass, or keyring." - .format(config["password_method"])) + "Valid methods: plain, pass, or keyring." + .format(config["password_method"])) def configure_connection(**kwargs): diff --git a/unittests/test_connection.py b/unittests/test_connection.py index 06838d1c15b70787be159b4ad2d7f1bb70abe6c8..26e3388dfa4dd7d360b8a373d631f5a362990f66 100644 --- a/unittests/test_connection.py +++ b/unittests/test_connection.py @@ -92,6 +92,8 @@ def test_make_uri_path(): def test_configure_connection(): + if not get_config().has_section("Connection"): + get_config().add_section("Connection") get_config().set("Connection", "url", "https://host.de") get_config().set("Connection", "username", "test_username") get_config().set("Connection", "password", "test_password")