Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serialization, deserialization function test in trivial cases #591

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/failed.yaml
Original file line number Diff line number Diff line change
@@ -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'
147 changes: 147 additions & 0 deletions tests/test_module.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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