From 2ab9c8e556a2bdac71364cca5fb61a3e7992c8bc Mon Sep 17 00:00:00 2001 From: Timm Fitschen <mail@timmfitschen.de> Date: Fri, 12 Oct 2018 13:49:05 +0200 Subject: [PATCH] STY: just formatting (mainly spaces) --- .../connection/authentication/external_credentials_provider.py | 1 + src/caosdb/connection/authentication/interface.py | 1 - src/caosdb/exceptions.py | 2 ++ unittests/test_authentication_external.py | 3 +++ unittests/test_authentication_keyring.py | 1 + unittests/test_authentication_pass.py | 3 ++- unittests/test_authentication_plain.py | 2 ++ 7 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/caosdb/connection/authentication/external_credentials_provider.py b/src/caosdb/connection/authentication/external_credentials_provider.py index 8164d49b..8795ee28 100644 --- a/src/caosdb/connection/authentication/external_credentials_provider.py +++ b/src/caosdb/connection/authentication/external_credentials_provider.py @@ -31,6 +31,7 @@ from .plain import PlainTextCredentialsProvider # meta class compatible with Python 2 *and* 3: ABC = ABCMeta(str('ABC'), (object, ), {str('__slots__'): ()}) + class ExternalCredentialsProvider(PlainTextCredentialsProvider, ABC): """ExternalCredentialsProvider. diff --git a/src/caosdb/connection/authentication/interface.py b/src/caosdb/connection/authentication/interface.py index fe9cb917..b705ab13 100644 --- a/src/caosdb/connection/authentication/interface.py +++ b/src/caosdb/connection/authentication/interface.py @@ -144,7 +144,6 @@ class AbstractAuthenticator(ABC): headers['Cookie'] = self._session_token - class CredentialsAuthenticator(AbstractAuthenticator): """CredentialsAuthenticator diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 485ad908..baa72b24 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -32,6 +32,7 @@ class CaosDBException(Exception): Exception.__init__(self, msg) self.msg = msg + class ConfigurationException(CaosDBException): """ConfigurationException. @@ -48,6 +49,7 @@ class ConfigurationException(CaosDBException): msg : str A description of the misconfiguration. """ + def __init__(self, msg): super(ConfigurationException, self).__init__(msg + ConfigurationException._INFO) diff --git a/unittests/test_authentication_external.py b/unittests/test_authentication_external.py index c595d38f..a5263859 100644 --- a/unittests/test_authentication_external.py +++ b/unittests/test_authentication_external.py @@ -10,9 +10,11 @@ from caosdb.connection.authentication import ( external_credentials_provider as ecp ) + class _TestCaller(ecp.ExternalCredentialsProvider): pass + def test_callback(): def _callback(**config): assert "opt" in config @@ -21,6 +23,7 @@ def test_callback(): t.configure(opt=None) assert t.password == "secret" + def test_log_password_incident(): class _mylogger(logging.Logger): def log(self, level, msg, *args, **kwargs): diff --git a/unittests/test_authentication_keyring.py b/unittests/test_authentication_keyring.py index 721adefd..1105b9d2 100644 --- a/unittests/test_authentication_keyring.py +++ b/unittests/test_authentication_keyring.py @@ -29,6 +29,7 @@ import sys from pytest import raises from caosdb.connection.authentication.keyring import KeyringCaller + def test_initialization(): def _callback(**config): assert not config diff --git a/unittests/test_authentication_pass.py b/unittests/test_authentication_pass.py index 968fdfd9..e5e4870c 100644 --- a/unittests/test_authentication_pass.py +++ b/unittests/test_authentication_pass.py @@ -27,10 +27,11 @@ Tests for the caosdb.connection.authentication.pass module. """ import sys from pytest import raises -_PASSCALLER="caosdb.connection.authentication.pass" +_PASSCALLER = "caosdb.connection.authentication.pass" __import__(_PASSCALLER) PassCaller = sys.modules[_PASSCALLER].PassCaller + def test_initialization(): def _callback(**config): assert not config diff --git a/unittests/test_authentication_plain.py b/unittests/test_authentication_plain.py index 6b59a231..26c57e95 100644 --- a/unittests/test_authentication_plain.py +++ b/unittests/test_authentication_plain.py @@ -30,6 +30,7 @@ from __future__ import unicode_literals from pytest import raises from caosdb.connection.authentication.plain import PlainTextCredentialsProvider + def test_subclass_configure(): """Test the correct passing of the password argument.""" class SubClassOf(PlainTextCredentialsProvider): @@ -53,6 +54,7 @@ def test_subclass_configure(): assert exc_info.value.args[0] == ("configure() got multiple values for " "keyword argument 'password'") + def test_plain_has_logger(): p = PlainTextCredentialsProvider() assert hasattr(p, "logger") -- GitLab