Skip to content
Snippets Groups Projects
Verified Commit 9a0c40a5 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'dev' into f-fsm

parents 6a6686e5 72133fef
Branches
Tags
1 merge request!3F fsm
...@@ -27,11 +27,18 @@ Unit tests for the modul caosdb.connection.authentication.plain. ...@@ -27,11 +27,18 @@ Unit tests for the modul caosdb.connection.authentication.plain.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
from pytest import raises
from caosdb.connection.authentication.plain import PlainTextCredentialsProvider from caosdb.connection.authentication.plain import PlainTextCredentialsProvider
from pytest import raises
def test_subclass_configure(): def test_subclass_configure():
# TODO I do not see the meaning of this test.
# It only tests, that the call of the super version of configure sets the
# password property. And that due to the subclassing no longer a password
# argument can be provided.
# Suggestion: Either remove this test or state in what context this test
# is meanigful.
"""Test the correct passing of the password argument.""" """Test the correct passing of the password argument."""
class SubClassOf(PlainTextCredentialsProvider): class SubClassOf(PlainTextCredentialsProvider):
"""A simple subclass of PlainTextCredentialsProvider.""" """A simple subclass of PlainTextCredentialsProvider."""
...@@ -51,7 +58,7 @@ def test_subclass_configure(): ...@@ -51,7 +58,7 @@ def test_subclass_configure():
with raises(TypeError) as exc_info: with raises(TypeError) as exc_info:
instance.configure(password="OH NO!") instance.configure(password="OH NO!")
assert exc_info.value.args[0] == ("configure() got multiple values for " assert exc_info.value.args[0].endswith("configure() got multiple values for "
"keyword argument 'password'") "keyword argument 'password'")
......
...@@ -24,17 +24,19 @@ ...@@ -24,17 +24,19 @@
"""Tests for the _ConcreteProperty class.""" """Tests for the _ConcreteProperty 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.common.models import _ConcreteProperty
from caosdb import configure_connection from caosdb import configure_connection
from caosdb.common.models import _ConcreteProperty
from caosdb.connection.mockup import MockUpServerConnection 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(): def setup_module():
there(_ConcreteProperty) there(_ConcreteProperty)
configure_connection(url="unittests", username="testuser", configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200, password="testpassword", timeout=200,
implementation=MockUpServerConnection) implementation=MockUpServerConnection)
......
...@@ -23,23 +23,27 @@ ...@@ -23,23 +23,27 @@
# #
"""Test caosdb.connection.""" """Test caosdb.connection."""
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from __future__ import unicode_literals, print_function from __future__ import print_function, unicode_literals
from builtins import bytes, str # pylint: disable=redefined-builtin
import re import re
from pytest import raises from builtins import bytes, str # pylint: disable=redefined-builtin
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 caosdb import execute_query 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(): def setup_module():
...@@ -96,6 +100,7 @@ def test_configure_connection(): ...@@ -96,6 +100,7 @@ def test_configure_connection():
get_config().add_section("Connection") get_config().add_section("Connection")
get_config().set("Connection", "url", "https://host.de") get_config().set("Connection", "url", "https://host.de")
get_config().set("Connection", "username", "test_username") 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", "password", "test_password")
get_config().set("Connection", "timeout", "200") get_config().set("Connection", "timeout", "200")
...@@ -152,6 +157,7 @@ def test_init_response(): ...@@ -152,6 +157,7 @@ def test_init_response():
response = MockUpResponse( response = MockUpResponse(
status=200, headers={"sessionToken": "SessionToken"}, body="Body") status=200, headers={"sessionToken": "SessionToken"}, body="Body")
there(response) there(response)
return response return response
...@@ -175,6 +181,7 @@ def test_getter_session_token(): ...@@ -175,6 +181,7 @@ def test_getter_session_token():
def test_init_connection(): def test_init_connection():
connection = MockUpServerConnection() connection = MockUpServerConnection()
there(connection) there(connection)
return connection return connection
...@@ -184,6 +191,7 @@ def test_resources_list(): ...@@ -184,6 +191,7 @@ def test_resources_list():
assert len(connection.resources) == 1 assert len(connection.resources) == 1
connection.resources.append(lambda **kwargs: test_init_response()) connection.resources.append(lambda **kwargs: test_init_response())
assert len(connection.resources) == 2 assert len(connection.resources) == 2
return connection return connection
...@@ -214,6 +222,7 @@ def setup_two_resources(): ...@@ -214,6 +222,7 @@ def setup_two_resources():
connection = test_init_connection() connection = test_init_connection()
connection.resources.extend([r1, r2, r3]) connection.resources.extend([r1, r2, r3])
return connection return connection
......
...@@ -35,6 +35,7 @@ class TestEntity(unittest.TestCase): ...@@ -35,6 +35,7 @@ class TestEntity(unittest.TestCase):
def setUp(self): def setUp(self):
self.assertIsNotNone(Entity) self.assertIsNotNone(Entity)
configure_connection(url="unittests", username="testuser", configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200, password="testpassword", timeout=200,
implementation=MockUpServerConnection) implementation=MockUpServerConnection)
......
...@@ -22,16 +22,18 @@ ...@@ -22,16 +22,18 @@
# ** end header # ** end header
# #
"""Tests for the File class.""" """Tests for the File class."""
# pylint: disable=missing-docstring from caosdb import File, Record, configure_connection
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.connection.mockup import MockUpServerConnection 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(): def setup_module():
there(File) there(File)
configure_connection(url="unittests", username="testuser", configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200, password="testpassword", timeout=200,
implementation=MockUpServerConnection) implementation=MockUpServerConnection)
......
...@@ -22,16 +22,18 @@ ...@@ -22,16 +22,18 @@
# ** end header # ** end header
# #
"""Tests for the RecordType class.""" """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 import Entity, RecordType, configure_connection
from caosdb.connection.mockup import MockUpServerConnection 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(): def setup_module():
there(RecordType) there(RecordType)
configure_connection(url="unittests", username="testuser", configure_connection(url="unittests", username="testuser",
password_method="plain",
password="testpassword", timeout=200, password="testpassword", timeout=200,
implementation=MockUpServerConnection) implementation=MockUpServerConnection)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment