diff --git a/src/linkahead/connection/mockup.py b/src/linkahead/connection/mockup.py index 9b69971c0409708f221c402f540fac85ff9c527e..d3bc13bb474a70d48446e8532607c3e11931ff05 100644 --- a/src/linkahead/connection/mockup.py +++ b/src/linkahead/connection/mockup.py @@ -75,7 +75,7 @@ class MockUpServerConnection(CaosDBServerConnection): just returns predefined responses which mimic the LinkAhead server.""" def __init__(self): - self.resources = [self._login] + self.resources = [self._login, self._logout] def _login(self, method, path, headers, body): if method == "POST" and path == "login": @@ -84,6 +84,12 @@ class MockUpServerConnection(CaosDBServerConnection): "mockup-auth-token"}, body="") + def _logout(self, method, path, headers, body): + if method in ["DELETE", "GET"] and path == "logout": + return MockUpResponse(200, + headers={}, + body="") + def configure(self, **kwargs): """This configure method does nothing.""" diff --git a/unittests/test_authentication_auth_token.py b/unittests/test_authentication_auth_token.py index 3142f1f9f54230cb19666eeb8ff5809a906f9d49..4eb17bcc3892a0d0cad0f2c86289c2e8c625d426 100644 --- a/unittests/test_authentication_auth_token.py +++ b/unittests/test_authentication_auth_token.py @@ -96,6 +96,6 @@ def test_logout_calls_delete(): auth_token="[request token]", implementation=MockUpServerConnection) - c._delegate_connection.resources.append(logout_resource) + c._delegate_connection.resources.insert(1, logout_resource) c._logout() mock.method.assert_called_once() diff --git a/unittests/test_connection.py b/unittests/test_connection.py index a3a1eff705c64f59baec33088906bdd9a4daa14d..d00d852e8f8c59535d8077ad8026a37d97891a6c 100644 --- a/unittests/test_connection.py +++ b/unittests/test_connection.py @@ -216,9 +216,9 @@ def test_init_connection(): def test_resources_list(): connection = test_init_connection() assert hasattr(connection, "resources") - assert len(connection.resources) == 1 - connection.resources.append(lambda **kwargs: test_init_response()) assert len(connection.resources) == 2 + connection.resources.append(lambda **kwargs: test_init_response()) + assert len(connection.resources) == 3 return connection