From 8c6cf42c88ad8e81b81077ad206afc37b97fbf3f Mon Sep 17 00:00:00 2001 From: Osman Hadzic Date: Thu, 31 Oct 2024 13:36:56 +0100 Subject: [PATCH] Update workflow to check code format - Add code formatting check to the astarte-ctl-test workflow. - Apply Black code formatting to the tests directory using the command `python -m black tests/`. Signed-off-by: Osman Hadzic --- .github/workflows/astarte-ctl-test.yaml | 6 +++++- .../test_app_engine_device_get_samples_error_cases.py | 2 +- tests/conftest.py | 7 ++++++- tests/pyproject.toml | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/astarte-ctl-test.yaml b/.github/workflows/astarte-ctl-test.yaml index 9c9bb06..34c82ed 100644 --- a/.github/workflows/astarte-ctl-test.yaml +++ b/.github/workflows/astarte-ctl-test.yaml @@ -139,7 +139,11 @@ jobs: - name: Install dependencies shell: bash - run: pip install -e ./tests + run: pip install -e ./tests + + - name: Format check + shell: bash + run: python -m black -l 100 --diff --check tests/ - name: Run tests shell: bash diff --git a/tests/app_engine/device/app_engine_device_get_samples/test_app_engine_device_get_samples_error_cases.py b/tests/app_engine/device/app_engine_device_get_samples/test_app_engine_device_get_samples_error_cases.py index 436b4ce..8ee7734 100644 --- a/tests/app_engine/device/app_engine_device_get_samples/test_app_engine_device_get_samples_error_cases.py +++ b/tests/app_engine/device/app_engine_device_get_samples/test_app_engine_device_get_samples_error_cases.py @@ -36,7 +36,7 @@ def test_get_sample_data_for_nonexisting_device(astarte_env_vars): assert "Device not found" in sample_data_result.stderr -def test_get_sample_data_for_nonexisting_interface(astarte_env_vars): +def test_get_sample_data_for_existing_device(astarte_env_vars): device_id = astarte_env_vars["device_test_1"] astarte_url = astarte_env_vars["astarte_url"] realm = astarte_env_vars["realm"] diff --git a/tests/conftest.py b/tests/conftest.py index 02e2fe6..870ed8a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,4 +20,9 @@ def astarte_env_vars(): astarte_url and realm and jwt ), "Environment variables for Astarte setup are not properly configured." - return {"astarte_url": astarte_url, "realm": realm, "jwt": jwt, "device_test_1": device_test_1} + return { + "astarte_url": astarte_url, + "realm": realm, + "jwt": jwt, + "device_test_1": device_test_1, + } diff --git a/tests/pyproject.toml b/tests/pyproject.toml index 8dd1125..dd96272 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -13,6 +13,7 @@ authors = [ ] dependencies = [ "pytest>=7.0.0", + "black>=23.1.0" ] classifiers = [ "Programming Language :: Python", @@ -24,7 +25,7 @@ classifiers = [ static = ["black", "pylint"] [tool.black] -line-length = 88 +line-length = 100 target-version = ["py312"] [tool.isort]