From 08172b76f061bfcc8bec7c3b4060cece71a071f8 Mon Sep 17 00:00:00 2001 From: Callahan Date: Mon, 29 Apr 2024 18:47:08 -0500 Subject: [PATCH] feat: add refresh-mode value 'ignore-running' (#4749) Snapd 2.57 allows a new value for `refresh-mode` named `ignore-running`. See https://github.com/snapcore/snapd/commit/33acdb6167735e23744a7e93149aec366c11ed03 Signed-off-by: Callahan Kovacs --- schema/snapcraft.json | 3 ++- snapcraft/models/project.py | 2 +- tests/legacy/unit/project/test_schema.py | 2 +- tests/unit/models/test_projects.py | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/schema/snapcraft.json b/schema/snapcraft.json index 3cc20cbaf3..11db2a21ec 100644 --- a/schema/snapcraft.json +++ b/schema/snapcraft.json @@ -775,7 +775,8 @@ "description": "controls if the app should be restarted at all", "enum": [ "endure", - "restart" + "restart", + "ignore-running" ] }, "stop-mode": { diff --git a/snapcraft/models/project.py b/snapcraft/models/project.py index f990011278..b8edd1cb6e 100644 --- a/snapcraft/models/project.py +++ b/snapcraft/models/project.py @@ -373,7 +373,7 @@ class App(models.CraftBaseModel): daemon: Optional[Literal["simple", "forking", "oneshot", "notify", "dbus"]] after: UniqueStrList = cast(UniqueStrList, []) before: UniqueStrList = cast(UniqueStrList, []) - refresh_mode: Optional[Literal["endure", "restart"]] + refresh_mode: Optional[Literal["endure", "restart", "ignore-running"]] stop_mode: Optional[ Literal[ "sigterm", diff --git a/tests/legacy/unit/project/test_schema.py b/tests/legacy/unit/project/test_schema.py index f22ef421e4..0e4f846d06 100644 --- a/tests/legacy/unit/project/test_schema.py +++ b/tests/legacy/unit/project/test_schema.py @@ -502,7 +502,7 @@ def test_valid_restart_conditions(data, condition): Validator(data).validate() -_REFRESH_MODES = ["endure", "restart"] +_REFRESH_MODES = ["endure", "restart", "ignore-running"] @pytest.mark.parametrize("mode", _REFRESH_MODES) diff --git a/tests/unit/models/test_projects.py b/tests/unit/models/test_projects.py index 0eba636ee4..f16c1b1eb0 100644 --- a/tests/unit/models/test_projects.py +++ b/tests/unit/models/test_projects.py @@ -951,7 +951,9 @@ def test_app_duplicate_before(self, app_yaml_data): with pytest.raises(errors.ProjectValidationError, match=error): Project.unmarshal(data) - @pytest.mark.parametrize("refresh_mode", ["endure", "restart", "_invalid"]) + @pytest.mark.parametrize( + "refresh_mode", ["endure", "restart", "ignore-running", "_invalid"] + ) def test_app_refresh_mode(self, refresh_mode, app_yaml_data): data = app_yaml_data(refresh_mode=refresh_mode)