Skip to content

Commit

Permalink
- Skip tests if Plex environmental variables are not set
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 committed Sep 21, 2022
1 parent 4b65ce0 commit 4756eca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def client() -> dizqueTV.API:
return dizqueTV.API(url=url, verbose=True)


def _plex_vars_exist() -> bool:
load_dotenv()
url = os.getenv("PLEX_URL")
token = os.getenv("PLEX_TOKEN")
return url is not None and token is not None


def _make_plex_utils() -> dizqueTV.PlexUtils:
load_dotenv()
url = os.getenv("PLEX_URL")
Expand Down
14 changes: 11 additions & 3 deletions tests/test_dizquetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
import pytest

import dizqueTV
from tests.setup import (client, fake_plex_server, plex_server,
from tests.setup import (client,
fake_plex_server,
plex_server,
_plex_vars_exist,
plex_server_as_dizquetv_server)

REAL_PLEX_SERVER_ADDED = False


@pytest.fixture()
def use_real_plex():
if not client().get_plex_server(plex_server().friendlyName):
yield client().add_plex_server_from_plexapi(plex_server())
else:
yield client().get_plex_server(plex_server().friendlyName)


def should_use_real_plex() -> bool:
return _plex_vars_exist()


class TestGeneral:
def test_dizquetv_server_details(self):
details = client().dizquetv_server_details
Expand Down Expand Up @@ -124,7 +130,9 @@ def test_delete_plex_server(self):


class TestWithRealPlex:
def test_use_real_plex(self, use_real_plex):
def test_use_real_plex(self):
if not should_use_real_plex():
pytest.skip("No real Plex server found")
server = use_real_plex
assert server is not None
assert type(server) == dizqueTV.PlexServer
Expand Down

0 comments on commit 4756eca

Please sign in to comment.