From 6d37e6abdc5ff5a2312bf1ed86e881f9b7c47a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Thu, 10 Dec 2020 17:14:25 +0100 Subject: [PATCH] STY+FIX --- tox.ini | 2 +- unittests/test_authentication_plain.py | 7 +++--- unittests/test_connection.py | 35 +++++++++++++++----------- unittests/test_entity.py | 1 + unittests/test_file.py | 10 +++++--- unittests/test_record_type.py | 8 +++--- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/tox.ini b/tox.ini index f9776382..94c2dc8a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py36, py37, py38 +envlist=py36, py37, py38, py39 skip_missing_interpreters = true [testenv] diff --git a/unittests/test_authentication_plain.py b/unittests/test_authentication_plain.py index 26c57e95..1b7cbf0c 100644 --- a/unittests/test_authentication_plain.py +++ b/unittests/test_authentication_plain.py @@ -27,8 +27,9 @@ Unit tests for the modul caosdb.connection.authentication.plain. """ from __future__ import unicode_literals -from pytest import raises + from caosdb.connection.authentication.plain import PlainTextCredentialsProvider +from pytest import raises def test_subclass_configure(): @@ -51,8 +52,8 @@ def test_subclass_configure(): with raises(TypeError) as exc_info: instance.configure(password="OH NO!") - assert exc_info.value.args[0] == ("configure() got multiple values for " - "keyword argument 'password'") + assert exc_info.value.args[0].endswith("configure() got multiple values for " + "keyword argument 'password'") def test_plain_has_logger(): diff --git a/unittests/test_connection.py b/unittests/test_connection.py index 5c1518c6..60f1b735 100644 --- a/unittests/test_connection.py +++ b/unittests/test_connection.py @@ -23,23 +23,27 @@ # """Test caosdb.connection.""" # pylint: disable=missing-docstring -from __future__ import unicode_literals, print_function -from builtins import bytes, str # pylint: disable=redefined-builtin +from __future__ import print_function, unicode_literals + import re -from pytest import raises -from nose.tools import (assert_equal as eq, assert_raises as raiz, assert_true - as tru, assert_is_not_none as there, assert_false as - falz) -from caosdb.exceptions import ConfigurationException, LoginFailedException -from caosdb.connection.utils import urlencode, make_uri_path, quote -from caosdb.connection.connection import ( - configure_connection, CaosDBServerConnection, - _DefaultCaosDBServerConnection) -from caosdb.connection.mockup import (MockUpServerConnection, MockUpResponse, - _request_log_message) -from caosdb.configuration import get_config, _reset_config -from caosdb.connection.authentication.interface import CredentialsAuthenticator +from builtins import bytes, str # pylint: disable=redefined-builtin + from caosdb import execute_query +from caosdb.configuration import _reset_config, get_config +from caosdb.connection.authentication.interface import CredentialsAuthenticator +from caosdb.connection.connection import (CaosDBServerConnection, + _DefaultCaosDBServerConnection, + configure_connection) +from caosdb.connection.mockup import (MockUpResponse, MockUpServerConnection, + _request_log_message) +from caosdb.connection.utils import make_uri_path, quote, urlencode +from caosdb.exceptions import ConfigurationException, LoginFailedException +from nose.tools import assert_equal as eq +from nose.tools import assert_false as falz +from nose.tools import assert_is_not_none as there +from nose.tools import assert_raises as raiz +from nose.tools import assert_true as tru +from pytest import raises def setup_module(): @@ -96,6 +100,7 @@ def test_configure_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_method", "plain") get_config().set("Connection", "password", "test_password") get_config().set("Connection", "timeout", "200") diff --git a/unittests/test_entity.py b/unittests/test_entity.py index d877e1ab..e98dfbef 100644 --- a/unittests/test_entity.py +++ b/unittests/test_entity.py @@ -35,6 +35,7 @@ class TestEntity(unittest.TestCase): def setUp(self): self.assertIsNotNone(Entity) configure_connection(url="unittests", username="testuser", + password_method="plain", password="testpassword", timeout=200, implementation=MockUpServerConnection) diff --git a/unittests/test_file.py b/unittests/test_file.py index 957c5780..3c80af7f 100644 --- a/unittests/test_file.py +++ b/unittests/test_file.py @@ -22,16 +22,18 @@ # ** end header # """Tests for the File class.""" -# pylint: disable=missing-docstring -from nose.tools import (assert_is_not_none as there, assert_true as tru, - assert_equal as eq) -from caosdb import Record, File, configure_connection +from caosdb import File, Record, configure_connection from caosdb.connection.mockup import MockUpServerConnection +# pylint: disable=missing-docstring +from nose.tools import assert_equal as eq +from nose.tools import assert_is_not_none as there +from nose.tools import assert_true as tru def setup_module(): there(File) configure_connection(url="unittests", username="testuser", + password_method="plain", password="testpassword", timeout=200, implementation=MockUpServerConnection) diff --git a/unittests/test_record_type.py b/unittests/test_record_type.py index c105220c..f31c56de 100644 --- a/unittests/test_record_type.py +++ b/unittests/test_record_type.py @@ -22,16 +22,18 @@ # ** end header # """Tests for the RecordType class.""" -# pylint: disable=missing-docstring -from nose.tools import (assert_is_not_none as there, assert_true as tru, - assert_equal as eq) from caosdb import Entity, RecordType, configure_connection from caosdb.connection.mockup import MockUpServerConnection +# pylint: disable=missing-docstring +from nose.tools import assert_equal as eq +from nose.tools import assert_is_not_none as there +from nose.tools import assert_true as tru def setup_module(): there(RecordType) configure_connection(url="unittests", username="testuser", + password_method="plain", password="testpassword", timeout=200, implementation=MockUpServerConnection) -- GitLab