Esempio n. 1
0
class DiskInitializationModuleTestCase(unittest.TestCase):
    """Test the disk initialization module."""
    def setUp(self):
        """Set up the module."""
        self.disk_init_module = DiskInitializationModule()

    def test_storage_property(self):
        """Test the storage property."""
        with pytest.raises(UnavailableStorageError):
            assert self.disk_init_module.storage is not None

        storage = Mock()
        self.disk_init_module.on_storage_changed(storage)
        assert self.disk_init_module.storage == storage

    def test_setup_kickstart(self):
        """Test setup_kickstart with storage."""
        storage = create_storage()
        data = Mock()

        self.disk_init_module.on_storage_changed(storage)
        self.disk_init_module.set_initialization_mode(
            InitializationMode.CLEAR_NONE)
        self.disk_init_module.setup_kickstart(data)

        assert data.clearpart.type == CLEARPART_TYPE_NONE
        assert data.clearpart.devices == []
        assert data.clearpart.drives == []
Esempio n. 2
0
class DiskInitializationModuleTestCase(unittest.TestCase):
    """Test the disk initialization module."""

    def setUp(self):
        """Set up the module."""
        self.disk_init_module = DiskInitializationModule()

    def storage_property_test(self):
        """Test the storage property."""
        with self.assertRaises(UnavailableStorageError):
            self.assertIsNotNone(self.disk_init_module.storage)

        storage = Mock()
        self.disk_init_module.on_storage_changed(storage)
        self.assertEqual(self.disk_init_module.storage, storage)

    def setup_kickstart_test(self):
        """Test setup_kickstart with storage."""
        storage = create_storage()
        data = Mock()

        self.disk_init_module.on_storage_changed(storage)
        self.disk_init_module.set_initialization_mode(InitializationMode.CLEAR_NONE)
        self.disk_init_module.setup_kickstart(data)

        self.assertEqual(data.clearpart.type, CLEARPART_TYPE_NONE)
        self.assertEqual(data.clearpart.devices, [])
        self.assertEqual(data.clearpart.drives, [])
Esempio n. 3
0
class DiskInitializationModuleTestCase(unittest.TestCase):
    """Test the disk initialization module."""

    def setUp(self):
        """Set up the module."""
        self.disk_init_module = DiskInitializationModule()

    def storage_property_test(self):
        """Test the storage property."""
        with self.assertRaises(UnavailableStorageError):
            self.assertIsNotNone(self.disk_init_module.storage)

        storage = Mock()
        self.disk_init_module.on_storage_reset(storage)
        self.assertEqual(self.disk_init_module.storage, storage)

    def setup_kickstart_test(self):
        """Test setup_kickstart with storage."""
        storage = create_storage()
        data = Mock()

        self.disk_init_module.on_storage_reset(storage)
        self.disk_init_module.set_initialization_mode(InitializationMode.CLEAR_NONE)
        self.disk_init_module.setup_kickstart(data)

        self.assertEqual(data.clearpart.type, CLEARPART_TYPE_NONE)
        self.assertEqual(data.clearpart.devices, [])
        self.assertEqual(data.clearpart.drives, [])