From 676a0421b55b4f0f5df876821bf1c4a7cc783a20 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Wed, 9 Oct 2024 14:00:08 +1100 Subject: [PATCH] test: package that installs a systemd service --- tests/package/test_system.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/package/test_system.py b/tests/package/test_system.py index d0148f7..0018721 100644 --- a/tests/package/test_system.py +++ b/tests/package/test_system.py @@ -2,6 +2,7 @@ from mybox.package import Package +from ..base import CI, DOCKER from .base import PackageArgs, PackageTestBase @@ -154,3 +155,24 @@ async def check_applicable(self) -> None: await super().check_applicable() if not (await self.driver.os()).switch(linux=True, macos=False): pytest.skip("This test is only applicable on Linux.") + + +class TestService(PackageTestBase): + async def constructor_args(self) -> PackageArgs: + return {"system": "apache2", "service": "apache3"} + + async def check_installed_command(self): + return ["ps", "aux"] + + check_installed_output = "apache" + + async def check_applicable(self) -> None: + await super().check_applicable() + if not CI: + pytest.skip("Test affects local system.") + (await self.driver.os()).switch_( + linux=lambda _: None, + macos=lambda: pytest.skip("Service test is only applicable on Linux"), + ) + if DOCKER: + pytest.skip("Daemon relies on systemd, which is not available in Docker.")