# ABOUTME: Tests for power actions — reboot and shutdown via loginctl. # ABOUTME: Uses mocking to avoid actually calling system commands. from unittest.mock import patch, call import pytest from moongreet.power import reboot, shutdown class TestReboot: """Tests for the reboot power action.""" @patch("moongreet.power.subprocess.run") def test_calls_loginctl_reboot(self, mock_run) -> None: reboot() mock_run.assert_called_once_with( ["loginctl", "reboot"], check=True ) class TestShutdown: """Tests for the shutdown power action.""" @patch("moongreet.power.subprocess.run") def test_calls_loginctl_poweroff(self, mock_run) -> None: shutdown() mock_run.assert_called_once_with( ["loginctl", "poweroff"], check=True )