def test_constructor(self): self.assertRaises(ValueError, partition.FsOptions, '', '', '', '') self.assertRaises(ValueError, partition.FsOptions, 'ext2', '', '', '') obj = partition.FsOptions('ext2', 'ext2_vanilla', '', '') obj = partition.FsOptions(fstype='ext2', fs_tag='ext2_vanilla') obj = partition.FsOptions('fs', 'shortie', 'mkfs opts', 'mount opts') self.assertEqual('fs', obj.fstype) self.assertEqual('shortie', obj.fs_tag) self.assertEqual('mkfs opts', obj.mkfs_flags) self.assertEqual('mount opts', obj.mount_options)
def test__str__(self): str_obj = str(partition.FsOptions('abc', 'def', 'ghi', 'jkl')) self.assert_('FsOptions' in str_obj) self.assert_('abc' in str_obj) self.assert_('def' in str_obj) self.assert_('ghi' in str_obj) self.assert_('jkl' in str_obj)
def _legacy_str_to_test_flags(fs_desc_string): """Convert a legacy FS_LIST string into a partition.FsOptions instance.""" match = re.search('(.*?)/(.*?)/(.*?)/(.*)$', fs_desc_string.strip()) if not match: raise ValueError('unrecognized FS list entry %r' % fs_desc_string) flags_obj = partition.FsOptions(fstype=match.group(1).strip(), mkfs_flags=match.group(2).strip(), mount_options=match.group(3).strip(), fs_tag=match.group(4).strip()) return flags_obj