From e343f48e4adbb970d25a7f315f4317dd8764498f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 2 Nov 2024 15:53:32 +0100 Subject: [PATCH 1/2] Add serialization, deserialization function test in trivial cases --- tests/test_module.py | 147 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/tests/test_module.py b/tests/test_module.py index 4908340577..7f6bbaa051 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,5 +1,9 @@ +from typing import Any + +import pytest from pydantic import BaseModel +from github_app_geo_project import module from github_app_geo_project.module.modules import MODULES from github_app_geo_project.module.tests import TestModule @@ -28,3 +32,146 @@ def test_conversions() -> None: def test_all_empty_status() -> None: for module in MODULES.values(): module.transversal_status_to_json(module.transversal_status_from_json({})) + + +class ConfigDictModule(module.Module[dict[str, Any], None, None]): + pass + + +@pytest.mark.parametrize( + "data", + [ + {}, + {"type": "success"}, + ], +) +def test_json_configuration_from_json(data) -> None: + test_module = ConfigDictModule() + + assert test_module.configuration_from_json(data) == data + + +class EventDataDictModule(module.Module[None, dict[str, Any], None]): + pass + + +@pytest.mark.parametrize( + "data", + [ + {}, + {"type": "success"}, + ], +) +def test_json_event_data_from_json(data) -> None: + test_module = EventDataDictModule() + + assert test_module.event_data_from_json(data) == data + + +@pytest.mark.parametrize( + "data", + [ + {}, + {"type": "success"}, + ], +) +def test_json_envent_data_to_json(data) -> None: + test_module = EventDataDictModule() + + assert test_module.event_data_to_json(data) == data + + +class TransversalStatusDictModule(module.Module[None, None, dict[str, Any]]): + pass + + +@pytest.mark.parametrize( + "data", + [ + {}, + {"type": "success"}, + ], +) +def test_json_transversal_status_from_json(data) -> None: + test_module = TransversalStatusDictModule() + + assert test_module.transversal_status_from_json(data) == data + + +@pytest.mark.parametrize( + "data", + [ + {}, + {"type": "success"}, + ], +) +def test_json_transversal_status_to_json(data) -> None: + test_module = TransversalStatusDictModule() + + assert test_module.transversal_status_to_json(data) == data + + +class Data(BaseModel): + value: str + + +class ConfigDataModule(module.Module[Data, None, None]): + pass + + +@pytest.mark.parametrize( + "data,expected", + [ + [{"value": "test"}, Data(value="test")], + ], +) +def test_data_configuration_from_json(data, expected) -> None: + test_module = ConfigDataModule() + + assert test_module.configuration_from_json(data) == expected + + +class EventDataDataModule(module.Module[None, Data, None]): + pass + + +@pytest.mark.parametrize( + "data,expected", + [ + [{"value": "test"}, Data(value="test")], + ], +) +def test_data_event_data_from_json(data, expected) -> None: + test_module = EventDataDataModule() + + assert test_module.event_data_from_json(data) == expected + + +@pytest.mark.parametrize("data,expected", [[Data(value="test"), {"value": "test"}]]) +def test_data_event_data_to_json(data, expected) -> None: + test_module = EventDataDataModule() + + assert test_module.event_data_to_json(data) == expected + + +class TransversalStatusDataModule(module.Module[None, None, Data]): + pass + + +@pytest.mark.parametrize( + "data,expected", + [ + [{"value": "test"}, Data(value="test")], + ], +) +def test_data_transversal_status_from_json(data, expected) -> None: + test_module = TransversalStatusDataModule() + + assert test_module.transversal_status_from_json(data) == expected + + +@pytest.mark.parametrize("data,expected", [[Data(value="test"), {"value": "test"}]]) +def test_data_transversal_status_to_json(data, expected) -> None: + test_module = TransversalStatusDataModule() + + assert test_module.transversal_status_to_json(data) == expected From 68404f76f1f26d571ae0d8ef0c612e8f8495d484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 2 Nov 2024 16:07:55 +0100 Subject: [PATCH 2/2] Add workflow to test the workflow dashboard --- .github/workflows/failed.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/failed.yaml diff --git a/.github/workflows/failed.yaml b/.github/workflows/failed.yaml new file mode 100644 index 0000000000..446dc2d458 --- /dev/null +++ b/.github/workflows/failed.yaml @@ -0,0 +1,24 @@ +# Used to test the workflow dashboard +name: Failed workflow + +on: + push: + branches: + - master + +jobs: + main1: + name: Main 1 + runs-on: ubuntu-24.04 + timeout-minutes: 1 + + steps: + - run: 'false' + + main2: + name: Main 2 + runs-on: ubuntu-24.04 + timeout-minutes: 1 + + steps: + - run: 'false'