From e163e732864f4978cffe0193ff02705b51c1d5c2 Mon Sep 17 00:00:00 2001 From: Joscha Schmiedt <joscha@schmiedt.dev> Date: Fri, 29 Mar 2024 22:04:33 +0100 Subject: [PATCH] STY: Fix style errors in unittests --- unittests/test_concrete_property.py | 9 ++++++--- unittests/test_connection.py | 10 +++++----- unittests/test_connection_utils.py | 23 ++++++++++++----------- unittests/test_exception.py | 2 +- unittests/test_high_level_api.py | 18 +++++++++--------- unittests/test_record_type.py | 1 + 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/unittests/test_concrete_property.py b/unittests/test_concrete_property.py index 6a55dcf9..32d38bbe 100644 --- a/unittests/test_concrete_property.py +++ b/unittests/test_concrete_property.py @@ -27,18 +27,21 @@ from linkahead import configure_connection from linkahead.common.models import _ConcreteProperty from linkahead.connection.mockup import MockUpServerConnection +from pytest import raises # pylint: disable=missing-docstring -def eq(a,b): + + +def eq(a, b): assert a == b + def there(a): assert a is not None + def tru(a): assert a -from pytest import raises - def setup_module(): there(_ConcreteProperty) diff --git a/unittests/test_connection.py b/unittests/test_connection.py index a4903fb3..a3a1eff7 100644 --- a/unittests/test_connection.py +++ b/unittests/test_connection.py @@ -39,19 +39,20 @@ from linkahead.connection.mockup import (MockUpResponse, MockUpServerConnection, from linkahead.connection.utils import make_uri_path, quote, urlencode from linkahead.exceptions import (ConfigurationError, LoginFailedError, LinkAheadConnectionError) +from pytest import raises -def eq(a,b): +def eq(a, b): assert a == b + def there(a): assert a is not None + def tru(a): assert a -from pytest import raises - def setup_function(function): configure_connection(url="http://localhost:8888/some/path", @@ -144,10 +145,9 @@ def test_configure_connection_bad_url(): def test_connection_interface(): - with raises(TypeError) as cm: CaosDBServerConnection() - + assert "Can't instantiate abstract class CaosDBServerConnection" in str(cm.value) tru(hasattr(CaosDBServerConnection, "request")) diff --git a/unittests/test_connection_utils.py b/unittests/test_connection_utils.py index 4f114783..d82cfde0 100644 --- a/unittests/test_connection_utils.py +++ b/unittests/test_connection_utils.py @@ -26,17 +26,6 @@ from __future__ import unicode_literals, print_function from pytest import raises -def eq(a,b): - assert a == b - -def there(a): - assert a is not None - -def tru(a): - assert a - -from pytest import raises - from linkahead.exceptions import ConfigurationError, LoginFailedError from linkahead.connection.utils import parse_auth_token, auth_token_to_cookie from linkahead.connection.connection import ( @@ -49,6 +38,18 @@ from linkahead.connection.authentication.interface import CredentialsAuthenticat from linkahead import execute_query +def eq(a, b): + assert a == b + + +def there(a): + assert a is not None + + +def tru(a): + assert a + + def setup_module(): _reset_config() diff --git a/unittests/test_exception.py b/unittests/test_exception.py index 23628bfd..1e54edbe 100644 --- a/unittests/test_exception.py +++ b/unittests/test_exception.py @@ -22,7 +22,7 @@ import warnings from linkahead.exceptions import (CaosDBConnectionError, CaosDBException, - LinkAheadConnectionError, LinkAheadException) + LinkAheadConnectionError, LinkAheadException) # make sure the deprecation is raised with warnings.catch_warnings(record=True) as w: diff --git a/unittests/test_high_level_api.py b/unittests/test_high_level_api.py index a47c21eb..be57e3c7 100644 --- a/unittests/test_high_level_api.py +++ b/unittests/test_high_level_api.py @@ -25,19 +25,19 @@ import linkahead as db from linkahead.high_level_api import (convert_to_entity, convert_to_python_object, - new_high_level_entity) + new_high_level_entity) from linkahead.high_level_api import (CaosDBPythonUnresolvedParent, - CaosDBPythonUnresolvedReference, - CaosDBPythonRecord, CaosDBPythonFile, - high_level_type_for_standard_type, - standard_type_for_high_level_type, - high_level_type_for_role, - CaosDBPythonEntity) + CaosDBPythonUnresolvedReference, + CaosDBPythonRecord, CaosDBPythonFile, + high_level_type_for_standard_type, + standard_type_for_high_level_type, + high_level_type_for_role, + CaosDBPythonEntity) from linkahead.apiutils import compare_entities from linkahead.common.datatype import (is_list_datatype, - get_list_datatype, - is_reference) + get_list_datatype, + is_reference) import pytest from lxml import etree diff --git a/unittests/test_record_type.py b/unittests/test_record_type.py index 87a3d229..8741950a 100644 --- a/unittests/test_record_type.py +++ b/unittests/test_record_type.py @@ -26,6 +26,7 @@ from linkahead import Entity, RecordType, configure_connection from linkahead.connection.mockup import MockUpServerConnection # pylint: disable=missing-docstring + def setup_module(): assert RecordType is not None configure_connection(url="unittests", username="testuser", -- GitLab