class TestFileSystemClicFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), 'root_dir') @patch('kiwi.filesystem.clicfs.Command.run') @patch('kiwi.filesystem.clicfs.mkdtemp') @patch('kiwi.filesystem.clicfs.LoopDevice') @patch('kiwi.filesystem.clicfs.FileSystemExt4') @patch('kiwi.filesystem.clicfs.SystemSize') @patch('kiwi.filesystem.clicfs.Path.wipe') def test_create_on_file( self, mock_wipe, mock_size, mock_ext4, mock_loop, mock_dtemp, mock_command ): size = mock.Mock() size.customize = mock.Mock( return_value=42 ) size.accumulate_mbyte_file_sizes = mock.Mock( return_value=42 ) mock_size.return_value = size filesystem = mock.Mock() mock_ext4.return_value = filesystem loop_provider = mock.Mock() mock_loop.return_value = loop_provider mock_dtemp.return_value = 'tmpdir' self.clicfs.create_on_file('myimage', 'label') size.accumulate_mbyte_file_sizes.assert_called_once_with() size.customize.assert_called_once_with(42, 'ext4') mock_loop.assert_called_once_with( 'tmpdir/fsdata.ext4', 42 ) loop_provider.create.assert_called_once_with() mock_ext4.assert_called_once_with( loop_provider, 'root_dir' ) filesystem.create_on_device.assert_called_once_with() assert mock_command.call_args_list == [ call( ['resize2fs', '-f', loop_provider.get_device(), '-M'] ), call( ['mkclicfs', 'tmpdir/fsdata.ext4', 'myimage'] ) ] @patch('kiwi.filesystem.clicfs.Path.wipe') def test_destructor(self, mock_wipe): self.clicfs.container_dir = 'tmpdir' self.clicfs.__del__() mock_wipe.assert_called_once_with('tmpdir')
class TestFileSystemClicFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), 'root_dir') @patch('kiwi.filesystem.clicfs.Command.run') @patch('kiwi.filesystem.clicfs.mkdtemp') @patch('kiwi.filesystem.clicfs.LoopDevice') @patch('kiwi.filesystem.clicfs.FileSystemExt4') @patch('kiwi.filesystem.clicfs.SystemSize') @patch('kiwi.filesystem.clicfs.Path.wipe') def test_create_on_file(self, mock_wipe, mock_size, mock_ext4, mock_loop, mock_dtemp, mock_command): size = mock.Mock() size.customize = mock.Mock(return_value=42) size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42) mock_size.return_value = size filesystem = mock.Mock() mock_ext4.return_value = filesystem loop_provider = mock.Mock() mock_loop.return_value = loop_provider mock_dtemp.return_value = 'tmpdir' self.clicfs.create_on_file('myimage', 'label') size.accumulate_mbyte_file_sizes.assert_called_once_with() size.customize.assert_called_once_with(42, 'ext4') mock_loop.assert_called_once_with('tmpdir/fsdata.ext4', 42) loop_provider.create.assert_called_once_with() mock_ext4.assert_called_once_with(loop_provider, 'root_dir') filesystem.create_on_device.assert_called_once_with() assert mock_command.call_args_list == [ call(['resize2fs', '-f', loop_provider.get_device(), '-M']), call(['mkclicfs', 'tmpdir/fsdata.ext4', 'myimage']) ] @patch('kiwi.filesystem.clicfs.Path.wipe') def test_destructor(self, mock_wipe): self.clicfs.container_dir = 'tmpdir' self.clicfs.__del__() mock_wipe.assert_called_once_with('tmpdir')
class TestFileSystemClicFs(object): @patch("os.path.exists") def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), "root_dir") @patch("kiwi.filesystem.clicfs.Command.run") @patch("kiwi.filesystem.clicfs.mkdtemp") @patch("kiwi.filesystem.clicfs.LoopDevice") @patch("kiwi.filesystem.clicfs.FileSystemExt4") @patch("kiwi.filesystem.clicfs.SystemSize") @patch("kiwi.filesystem.clicfs.Path.wipe") def test_create_on_file(self, mock_wipe, mock_size, mock_ext4, mock_loop, mock_dtemp, mock_command): size = mock.Mock() size.customize = mock.Mock(return_value=42) size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42) mock_size.return_value = size filesystem = mock.Mock() mock_ext4.return_value = filesystem loop_provider = mock.Mock() mock_loop.return_value = loop_provider mock_dtemp.return_value = "tmpdir" self.clicfs.create_on_file("myimage", "label") size.accumulate_mbyte_file_sizes.assert_called_once_with() size.customize.assert_called_once_with(42, "ext4") mock_loop.assert_called_once_with("tmpdir/fsdata.ext4", 42) loop_provider.create.assert_called_once_with() mock_ext4.assert_called_once_with(loop_provider, "root_dir") filesystem.create_on_device.assert_called_once_with() assert mock_command.call_args_list == [ call(["resize2fs", "-f", loop_provider.get_device(), "-M"]), call(["mkclicfs", "tmpdir/fsdata.ext4", "myimage"]), ] @patch("kiwi.filesystem.clicfs.Path.wipe") def test_destructor(self, mock_wipe): self.clicfs.container_dir = "tmpdir" self.clicfs.__del__() mock_wipe.assert_called_once_with("tmpdir")
class TestFileSystemClicFs: @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), 'root_dir') @patch('os.path.exists') def setup_method(self, cls, mock_exists): self.setup() @patch('kiwi.filesystem.clicfs.Command.run') @patch('kiwi.filesystem.clicfs.Temporary') @patch('kiwi.filesystem.clicfs.LoopDevice') @patch('kiwi.filesystem.clicfs.FileSystemExt4') @patch('kiwi.filesystem.clicfs.SystemSize') def test_create_on_file(self, mock_size, mock_ext4, mock_loop, mock_Temporary, mock_command): size = mock.Mock() size.customize = mock.Mock(return_value=42) size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42) mock_size.return_value = size filesystem = mock.Mock() mock_ext4.return_value = filesystem loop_provider = mock.Mock() mock_loop.return_value = loop_provider mock_Temporary.return_value.new_dir.return_value.name = 'tmpdir' self.clicfs.create_on_file('myimage', 'label') size.accumulate_mbyte_file_sizes.assert_called_once_with() size.customize.assert_called_once_with(42, 'ext4') mock_loop.assert_called_once_with('tmpdir/fsdata.ext4', 42) loop_provider.create.assert_called_once_with() mock_ext4.assert_called_once_with(loop_provider, 'root_dir') filesystem.create_on_device.assert_called_once_with() assert mock_command.call_args_list == [ call(['resize2fs', '-f', loop_provider.get_device(), '-M']), call(['mkclicfs', 'tmpdir/fsdata.ext4', 'myimage']) ]
def __new__(self, name, device_provider, root_dir=None, custom_args=None): if name == 'ext2': return FileSystemExt2(device_provider, root_dir, custom_args) elif name == 'ext3': return FileSystemExt3(device_provider, root_dir, custom_args) elif name == 'ext4': return FileSystemExt4(device_provider, root_dir, custom_args) elif name == 'btrfs': return FileSystemBtrfs(device_provider, root_dir, custom_args) elif name == 'xfs': return FileSystemXfs(device_provider, root_dir, custom_args) elif name == 'fat16': return FileSystemFat16(device_provider, root_dir, custom_args) elif name == 'fat32': return FileSystemFat32(device_provider, root_dir, custom_args) elif name == 'squashfs': return FileSystemSquashFs(device_provider, root_dir, custom_args) elif name == 'clicfs': return FileSystemClicFs(device_provider, root_dir, custom_args) elif name == 'swap': return FileSystemSwap(device_provider, root_dir, custom_args) else: raise KiwiFileSystemSetupError( 'Support for %s filesystem not implemented' % name)
def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), "root_dir")
def setup(self, mock_exists): mock_exists.return_value = True self.clicfs = FileSystemClicFs(mock.Mock(), 'root_dir')