diff --git a/.github/workflows/failed.yaml b/.github/workflows/failed.yaml new file mode 100644 index 00000000000..446dc2d4585 --- /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' diff --git a/tests/test_module.py b/tests/test_module.py index 49083405772..7f6bbaa051e 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