function to check login status
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from delta_barth.api import common
|
||||
from delta_barth.constants import HTTP_CONTENT_HEADERS
|
||||
from delta_barth.errors import UnknownApiErrorCode, UnspecifiedRequestType
|
||||
from delta_barth.constants import HTTP_CURRENT_CONNECTION
|
||||
from delta_barth.errors import (
|
||||
ApiConnectionError,
|
||||
UnknownApiErrorCode,
|
||||
UnspecifiedRequestType,
|
||||
)
|
||||
from delta_barth.types import HttpRequestTypes
|
||||
|
||||
"http://test.com/ "
|
||||
@@ -44,6 +48,11 @@ def test_combine_route(base, route, expect):
|
||||
assert res == expect
|
||||
|
||||
|
||||
def test_assert_login():
|
||||
with pytest.raises(ApiConnectionError):
|
||||
common._assert_login()
|
||||
|
||||
|
||||
@pytest.mark.api_con_required
|
||||
def test_ping(api_base_url):
|
||||
resp = common.ping(api_base_url, HttpRequestTypes.GET)
|
||||
@@ -66,7 +75,7 @@ def test_raise_unknown_error(api_base_url):
|
||||
|
||||
@pytest.mark.api_con_required
|
||||
def test_login_logout(credentials, api_base_url):
|
||||
assert HTTP_CONTENT_HEADERS.session_token is None
|
||||
assert HTTP_CURRENT_CONNECTION.session_token is None
|
||||
resp = common.login(
|
||||
base_url=api_base_url,
|
||||
user_name=credentials["user"],
|
||||
@@ -75,12 +84,12 @@ def test_login_logout(credentials, api_base_url):
|
||||
mandant=credentials["mandant"],
|
||||
)
|
||||
assert resp.error is None
|
||||
assert HTTP_CONTENT_HEADERS.session_token is not None
|
||||
assert HTTP_CURRENT_CONNECTION.session_token is not None
|
||||
resp = common.logout(
|
||||
base_url=api_base_url,
|
||||
)
|
||||
assert HTTP_CONTENT_HEADERS.session_token is None
|
||||
assert "DelecoToken" not in HTTP_CONTENT_HEADERS
|
||||
assert HTTP_CURRENT_CONNECTION.session_token is None
|
||||
assert "DelecoToken" not in HTTP_CURRENT_CONNECTION
|
||||
resp = common.login(
|
||||
base_url=api_base_url,
|
||||
user_name=credentials["user"],
|
||||
|
||||
Reference in New Issue
Block a user