diff --git a/.github/workflows/python-unittest.yml b/.github/workflows/python-test.yml similarity index 86% rename from .github/workflows/python-unittest.yml rename to .github/workflows/python-test.yml index 1624b21..6cbf408 100644 --- a/.github/workflows/python-unittest.yml +++ b/.github/workflows/python-test.yml @@ -18,9 +18,9 @@ jobs: runs-on: ubuntu-latest environment: ev_kirche_baiersbronn steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5.3.0 with: python-version: '3.x' @@ -37,8 +37,8 @@ jobs: env: POETRY_HOME: ${{ github.workspace }}/.poetry - - name: Run unittests + - name: Run Tests run: | - python -m unittest tests.test_ChurchWebHelper + pytest tests/* env: POETRY_HOME: ${{ github.workspace }}/.poetry \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index e491606..fb21838 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,13 +1,8 @@ { - "python.testing.unittestArgs": [ - "-v", - "-s", - "./tests", - "-p", - "test_*.py" - ], - "python.testing.pytestEnabled": false, - "python.testing.unittestEnabled": true, + "python.testing.defaultTestFramework": "pytest", + "python.testing.pytestEnabled": true, + "python.testing.pytestPath": "/tests", + "python.testing.unittestEnabled": false, "githubPullRequests.ignoredPullRequestBranches": [ "master" ], diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_ChurchWebHelper.py b/tests/test_ChurchWebHelper.py index 72ed1a0..98cb9e5 100644 --- a/tests/test_ChurchWebHelper.py +++ b/tests/test_ChurchWebHelper.py @@ -3,7 +3,7 @@ import logging import logging.config import os -import unittest +import pytest from pathlib import Path from churchtools_api.churchtools_api import ChurchToolsApi @@ -18,15 +18,14 @@ log_directory.mkdir(parents=True) logging.config.dictConfig(config=logging_config) -class TestsChurchWebHelper(unittest.TestCase): - def __init__(self, *args, **kwargs) -> None: - super().__init__(*args, **kwargs) +class TestsChurchWebHelper(): + def setup_class(self, *args, **kwargs) -> None: if "CT_TOKEN" in os.environ: self.ct_token = os.environ["CT_TOKEN"] self.ct_domain = os.environ["CT_DOMAIN"] - users_string = os.environ["CT_USERS"] - self.ct_users = ast.literal_eval(users_string) + #users_string = os.environ["CT_USERS"] + #self.ct_users = ast.literal_eval(users_string) logger.info( "using connection details provided with ENV variables") else: @@ -42,9 +41,7 @@ def __init__(self, *args, **kwargs) -> None: self.api = ChurchToolsApi( domain=self.ct_domain, ct_token=self.ct_token) - logger.basicConfig(filename="logs/TestsChurchToolsApi.log", encoding="utf-8", - format="%(asctime)s %(name)-10s %(levelname)-8s %(message)s", - level=logger.DEBUG) + logger.info("Executing Tests RUN") def tearDown(self)->None: