Exemplo n.º 1
0
class StorageCheckerInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the storage checker module."""

    def setUp(self):
        self.module = StorageCheckerModule()
        self.interface = StorageCheckerInterface(self.module)

    @patch.dict(storage_checker.constraints)
    def test_set_constraint(self):
        """Test SetConstraint."""
        self.interface.SetConstraint(
            STORAGE_MIN_RAM,
            get_variant(Int, 987 * 1024 * 1024)
        )

        self.assertEqual(storage_checker.constraints[STORAGE_MIN_RAM], Size("987 MiB"))

        with self.assertRaises(UnsupportedValueError) as cm:
            self.interface.SetConstraint(
                STORAGE_LUKS2_MIN_RAM,
                get_variant(Int, 987 * 1024 * 1024)
            )

        self.assertEqual(str(cm.exception), "Constraint 'luks2_min_ram' is not supported.")
        self.assertEqual(storage_checker.constraints[STORAGE_LUKS2_MIN_RAM], Size("128 MiB"))
class StorageCheckerInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the storage checker module."""
    def setUp(self):
        self.module = StorageCheckerModule()
        self.interface = StorageCheckerInterface(self.module)

    def set_constraint_test(self):
        """Test SetConstraint."""
        with patch.dict(storage_checker.constraints):
            self.interface.SetConstraint(STORAGE_MIN_RAM, 987)
            self.assertEqual(storage_checker.constraints[STORAGE_MIN_RAM], 987)
Exemplo n.º 3
0
 def setUp(self):
     self.module = StorageCheckerModule()
     self.interface = StorageCheckerInterface(self.module)
Exemplo n.º 4
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(STORAGE_CHECKER.object_path, StorageCheckerInterface(self))