Skip to content
Snippets Groups Projects
Commit 6321ed77 authored by I. Nüske's avatar I. Nüske
Browse files

TST: Added support for logout to MockUpServerConnection and tests to fix...

TST: Added support for logout to MockUpServerConnection and tests to fix test_auth_token_connection in test_connection.py
parent dbddca1e
No related branches found
No related tags found
2 merge requests!175BUG: Request responses without the "Set-Cookie" header no longer overwrite the...,!162Prevent auth_token from being overwritten with None
Pipeline #57886 passed with warnings
This commit is part of merge request !162. Comments created here will be created in the context of that merge request.
......@@ -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."""
......
......@@ -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()
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment