diff --git a/tests/apitest_shared.py b/tests/apitest_shared.py index 5fd742b..3840109 100644 --- a/tests/apitest_shared.py +++ b/tests/apitest_shared.py @@ -1,4 +1,7 @@ import os + +from functools import lru_cache + import pytest from personio_py import Personio, PersonioError @@ -8,25 +11,15 @@ CLIENT_SECRET = os.getenv('CLIENT_SECRET') personio = Personio(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) -shared_test_data = {} # deactivate all tests that rely on a specific personio instance try: personio.authenticate() can_authenticate = True - # This is used to ensure the test check for existing objects - test_employee = personio.get_employees()[0] - shared_test_data = { - 'test_employee': { - 'id': test_employee.id_, - 'first_name': test_employee.first_name, - 'last_name': test_employee.last_name, - 'email': test_employee.email, - 'hire_date': test_employee.hire_date - } - } except PersonioError: can_authenticate = False skip_if_no_auth = pytest.mark.skipif(not can_authenticate, reason="Personio authentication failed") - +@lru_cache(maxsize=1) +def get_test_employee(): + return personio.get_employees()[0] diff --git a/tests/test_api_raw.py b/tests/test_api_raw.py index 4adf618..557bce0 100644 --- a/tests/test_api_raw.py +++ b/tests/test_api_raw.py @@ -1,4 +1,4 @@ -from .apitest_shared import * +from tests.apitest_shared import * @skip_if_no_auth