Skip to content

Commit

Permalink
Place authentication in importable file for use with test cases place…
Browse files Browse the repository at this point in the history
…d in multiple files (at-gmbh#11)

* Place authentication in importable file for use with test cases placed in multiple files

* Readd existing tests

* Update import statement

* Don't use shared_test_data dict, cache retrieval of valid online user

* Don't require python3.8 to run the tests

* cleanup

Co-authored-by: Sebastian Straub <[email protected]>
  • Loading branch information
Philip Flohr and klamann committed Jan 14, 2021
1 parent eac9a0f commit 3946845
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/apitest_shared.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import os
import pytest

from functools import lru_cache

import pytest

from personio_py import Personio, PersonioError

# Personio client authentication
CLIENT_ID = os.getenv('CLIENT_ID')
CLIENT_SECRET = os.getenv('CLIENT_SECRET')
personio = Personio(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)


@lru_cache(maxsize=1)
def get_test_employee():
return personio.get_employees()[0]


# 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
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]

0 comments on commit 3946845

Please sign in to comment.