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

STY: autopep8'd

parent 4f1e4266
Branches
Tags
No related merge requests found
...@@ -163,7 +163,8 @@ def setup_package(): ...@@ -163,7 +163,8 @@ def setup_package():
tests_require=["pytest", "pytest-cov", "coverage>=4.4.2"], tests_require=["pytest", "pytest-cov", "coverage>=4.4.2"],
package_data={ package_data={
'caosdb': ['cert/indiscale.ca.crt'], 'caosdb': ['cert/indiscale.ca.crt'],
} },
scripts=["src/caosdb/utils/caosdb_admin.py"]
) )
try: try:
setup(**metadata) setup(**metadata)
......
...@@ -3516,6 +3516,7 @@ class UserInfo(): ...@@ -3516,6 +3516,7 @@ class UserInfo():
self.name = xml.get("username") self.name = xml.get("username")
self.realm = xml.get("realm") self.realm = xml.get("realm")
class Info(): class Info():
def __init__(self): def __init__(self):
......
...@@ -41,6 +41,7 @@ def _make_params(pos_args, opts): ...@@ -41,6 +41,7 @@ def _make_params(pos_args, opts):
result["-p{i}".format(i=i)] = str(val) result["-p{i}".format(i=i)] = str(val)
return result return result
def _make_multipart_request(call, pos_args, opts, files): def _make_multipart_request(call, pos_args, opts, files):
parts = list() parts = list()
params = _make_params(pos_args, opts) params = _make_params(pos_args, opts)
...@@ -56,6 +57,7 @@ def _make_multipart_request(call, pos_args, opts, files): ...@@ -56,6 +57,7 @@ def _make_multipart_request(call, pos_args, opts, files):
body, headers = multipart_encode(parts) body, headers = multipart_encode(parts)
return body, headers return body, headers
def _make_form_request(call, pos_args, opts): def _make_form_request(call, pos_args, opts):
form = dict() form = dict()
form["call"] = call form["call"] = call
...@@ -64,11 +66,11 @@ def _make_form_request(call, pos_args, opts): ...@@ -64,11 +66,11 @@ def _make_form_request(call, pos_args, opts):
for key, val in params.items(): for key, val in params.items():
form[key] = val form[key] = val
headers = {} headers = {}
headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Content-Type"] = "application/x-www-form-urlencoded"
return urlencode(form), headers return urlencode(form), headers
def _make_request(call, pos_args, opts, files=None): def _make_request(call, pos_args, opts, files=None):
""" """
Return Return
...@@ -81,6 +83,7 @@ def _make_request(call, pos_args, opts, files=None): ...@@ -81,6 +83,7 @@ def _make_request(call, pos_args, opts, files=None):
return _make_form_request(call, pos_args, opts) return _make_form_request(call, pos_args, opts)
def run_server_side_script(call, *args, files=None, **kwargs): def run_server_side_script(call, *args, files=None, **kwargs):
""" """
......
...@@ -35,16 +35,19 @@ from caosdb.connection.utils import parse_auth_token ...@@ -35,16 +35,19 @@ from caosdb.connection.utils import parse_auth_token
from caosdb.exceptions import LoginFailedException from caosdb.exceptions import LoginFailedException
from caosdb import configure_connection from caosdb import configure_connection
def test_get_authentication_provider(): def test_get_authentication_provider():
ap = at.get_authentication_provider() ap = at.get_authentication_provider()
assert isinstance(ap, at.AuthTokenAuthenticator) assert isinstance(ap, at.AuthTokenAuthenticator)
def response_with_auth_token(): def response_with_auth_token():
token = "SessionToken=[response token];" token = "SessionToken=[response token];"
assert parse_auth_token(token) is not None, "cookie not ok" assert parse_auth_token(token) is not None, "cookie not ok"
return MockUpResponse(200, {"Set-Cookie": token}, "ok") return MockUpResponse(200, {"Set-Cookie": token}, "ok")
def test_configure_connection(): def test_configure_connection():
def request_has_auth_token(**kwargs): def request_has_auth_token(**kwargs):
"""test resources""" """test resources"""
...@@ -65,6 +68,7 @@ def test_configure_connection(): ...@@ -65,6 +68,7 @@ def test_configure_connection():
assert response.read() == "ok" assert response.read() == "ok"
assert c._authenticator.auth_token == "[response token]" assert c._authenticator.auth_token == "[response token]"
def test_login_raises(): def test_login_raises():
c = configure_connection(password_method="auth_token", c = configure_connection(password_method="auth_token",
auth_token="[auth_token]") auth_token="[auth_token]")
...@@ -94,4 +98,3 @@ def test_logout_calls_delete(): ...@@ -94,4 +98,3 @@ def test_logout_calls_delete():
c._delegate_connection.resources.append(logout_resource) c._delegate_connection.resources.append(logout_resource)
c._logout() c._logout()
mock.method.assert_called_once() mock.method.assert_called_once()
...@@ -41,6 +41,7 @@ def test_get_authentication_provider(): ...@@ -41,6 +41,7 @@ def test_get_authentication_provider():
ap = unauthenticated.get_authentication_provider() ap = unauthenticated.get_authentication_provider()
assert isinstance(ap, unauthenticated.Unauthenticated) assert isinstance(ap, unauthenticated.Unauthenticated)
def test_configure_connection(): def test_configure_connection():
mock = Mock() mock = Mock()
...@@ -67,10 +68,3 @@ def test_login_raises(): ...@@ -67,10 +68,3 @@ def test_login_raises():
c = configure_connection(password_method="unauthenticated") c = configure_connection(password_method="unauthenticated")
with raises(LoginFailedException): with raises(LoginFailedException):
c._login() c._login()
...@@ -285,4 +285,3 @@ def test_auth_token_connection(): ...@@ -285,4 +285,3 @@ def test_auth_token_connection():
"auth_token authenticator cannot log in " "auth_token authenticator cannot log in "
"again. You must provide a new authentication " "again. You must provide a new authentication "
"token.") "token.")
...@@ -45,6 +45,7 @@ def test_property_access(): ...@@ -45,6 +45,7 @@ def test_property_access():
assert rec.get_property("prop") is not None assert rec.get_property("prop") is not None
assert rec.get_property("prOp") is not None assert rec.get_property("prOp") is not None
def test_get_parent_by_name(): def test_get_parent_by_name():
rec = Record(id="123") rec = Record(id="123")
rec.add_parent(name="Test") rec.add_parent(name="Test")
...@@ -54,12 +55,14 @@ def test_get_parent_by_name(): ...@@ -54,12 +55,14 @@ def test_get_parent_by_name():
assert rec.get_parent("test") is not None assert rec.get_parent("test") is not None
assert rec.get_parent("tEsT") is not None assert rec.get_parent("tEsT") is not None
def test_get_parent_by_id(): def test_get_parent_by_id():
rec = Record(id="123") rec = Record(id="123")
rec.add_parent(234) rec.add_parent(234)
assert rec.get_parent(None) is None assert rec.get_parent(None) is None
assert rec.get_parent(234) is not None assert rec.get_parent(234) is not None
def test_get_parent_by_entity(): def test_get_parent_by_entity():
rec = Record(id="123") rec = Record(id="123")
rt = RecordType("Test", id=234) rt = RecordType("Test", id=234)
......
...@@ -7,6 +7,7 @@ from caosdb import configure_connection ...@@ -7,6 +7,7 @@ from caosdb import configure_connection
_REMOVE_FILES_AFTERWARDS = [] _REMOVE_FILES_AFTERWARDS = []
def setup_module(): def setup_module():
c = configure_connection(password_method="unauthenticated", c = configure_connection(password_method="unauthenticated",
implementation=MockUpServerConnection) implementation=MockUpServerConnection)
...@@ -15,6 +16,7 @@ def setup_module(): ...@@ -15,6 +16,7 @@ def setup_module():
' <stdout>{stdout}</stdout>' ' <stdout>{stdout}</stdout>'
' <stderr>{stderr}</stderr>' ' <stderr>{stderr}</stderr>'
'</script></Response>') '</script></Response>')
def scripting_resource(**kwargs): def scripting_resource(**kwargs):
assert kwargs["path"] == "scripting" assert kwargs["path"] == "scripting"
content_type = kwargs["headers"]["Content-Type"] content_type = kwargs["headers"]["Content-Type"]
...@@ -39,6 +41,7 @@ def setup_module(): ...@@ -39,6 +41,7 @@ def setup_module():
return MockUpResponse(200, {}, scripting_response) return MockUpResponse(200, {}, scripting_response)
c._delegate_connection.resources.append(scripting_resource) c._delegate_connection.resources.append(scripting_resource)
def teardown_module(): def teardown_module():
from os import remove from os import remove
from os.path import exists, isdir from os.path import exists, isdir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment