From 1b2c889b1935f3d3b8ec4766b1f9f3d2b8204b1f Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 7 Sep 2024 00:36:03 -0500 Subject: [PATCH] trivial: integration tests: Add helpers for checking if actions enabled or disabled --- tests/integration_test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/integration_test.py b/tests/integration_test.py index e03c8f4..e2e5607 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -478,6 +478,26 @@ class Tests(dbusmock.DBusTestCase): + f"'{self.get_dbus_property(prop)}'", ) + def _assert_action_boolean(self, name, value): + for action in self.get_dbus_property("Actions"): + if action["Name"] != name: + continue + self.assertEqual(action["Enabled"], value) + + def assert_action_disabled(self, name): + """Assert that a PPD action is disabled""" + if self.PP_INTERFACE == "org.freedesktop.UPower.PowerProfiles": + self._assert_action_boolean(name, False) + else: + self.assertNotIn(name, self.get_dbus_property("Actions")) + + def assert_action_enabled(self, name): + """Assert that a PPD action is enabled""" + if self.PP_INTERFACE == "org.freedesktop.UPower.PowerProfiles": + self._assert_action_boolean(name, True) + else: + self.assertIn(name, self.get_dbus_property("Actions")) + # # Actual test cases #