From 97335574638410ff5a093586cbf078eebe148269 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 19 Nov 2023 23:05:48 +0100 Subject: [PATCH] Added a few basic tests --- .gitea/workflows/tests.yml | 2 ++ tests/conftest.py | 15 +++++++++++++++ tests/test_client.py | 8 ++++++++ tests/test_raw.py | 7 +++++++ tox.ini | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/conftest.py create mode 100644 tests/test_client.py create mode 100644 tests/test_raw.py diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 3bb6bde..3bd100f 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -18,6 +18,8 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: + env: + RMV_TOKEN: ${{ secrets.RMV_TOKEN }} - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..8fff836 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +from os import environ + +import pytest + +from pyrmv import Client + + +@pytest.fixture() +def api_token() -> str: + return environ.get("RMV_TOKEN") + + +@pytest.fixture() +def api_client(api_token: str) -> Client: + return Client(api_token) diff --git a/tests/test_client.py b/tests/test_client.py new file mode 100644 index 0000000..071a465 --- /dev/null +++ b/tests/test_client.py @@ -0,0 +1,8 @@ +import pytest + +from pyrmv import Client +from pyrmv.classes import Stop + + +def test_stop_by_name(api_client: Client): + assert isinstance(api_client.stop_by_name("Hauptwache", max_number=1)[0], Stop) diff --git a/tests/test_raw.py b/tests/test_raw.py new file mode 100644 index 0000000..f95b19e --- /dev/null +++ b/tests/test_raw.py @@ -0,0 +1,7 @@ +import pytest + +from pyrmv.raw import stop_by_name + + +def test_stop_by_name(api_token: str): + assert isinstance(stop_by_name(api_token, "Hauptwache", maxNo=1), dict) diff --git a/tox.ini b/tox.ini index 32050e0..85167c2 100644 --- a/tox.ini +++ b/tox.ini @@ -18,5 +18,5 @@ deps = -r{toxinidir}/requirements/_.txt -r{toxinidir}/requirements/dev.txt commands = - pytest --basetemp={envtmpdir} --cov=cringepredictor --cov-report term-missing + pytest --basetemp={envtmpdir} --cov=pyrmv --cov-report term-missing