diff --git a/tests/storage_tests/formats_test/labeling_test.py b/tests/storage_tests/formats_test/labeling_test.py index 067b900b1..513ec619d 100644 --- a/tests/storage_tests/formats_test/labeling_test.py +++ b/tests/storage_tests/formats_test/labeling_test.py @@ -1,6 +1,3 @@ -import unittest - -from blivet.formats import device_formats from blivet.size import Size import blivet.formats.fs as fs import blivet.formats.swap as swap @@ -9,42 +6,6 @@ from . import fslabeling -class InitializationTestCase(unittest.TestCase): - - """Test FS object initialization.""" - - def test_labels(self): - """Initialize some filesystems with valid and invalid labels.""" - - # Ext2FS has a maximum length of 16 - self.assertFalse(fs.Ext2FS().label_format_ok("root___filesystem")) - self.assertTrue(fs.Ext2FS().label_format_ok("root__filesystem")) - - # FATFS has a maximum length of 11 - self.assertFalse(fs.FATFS().label_format_ok("rtfilesystem")) - self.assertTrue(fs.FATFS().label_format_ok("rfilesystem")) - - # XFS has a maximum length 12 and does not allow spaces - self.assertFalse(fs.XFS().label_format_ok("root_filesyst")) - self.assertFalse(fs.XFS().label_format_ok("root file")) - self.assertTrue(fs.XFS().label_format_ok("root_filesys")) - - # HFSPlus has a maximum length of 128, minimum length of 1, and does not allow colons - self.assertFalse(fs.HFSPlus().label_format_ok("n" * 129)) - self.assertFalse(fs.HFSPlus().label_format_ok("root:file")) - self.assertFalse(fs.HFSPlus().label_format_ok("")) - self.assertTrue(fs.HFSPlus().label_format_ok("n" * 128)) - - # NTFS has a maximum length of 128 - self.assertFalse(fs.NTFS().label_format_ok("n" * 129)) - self.assertTrue(fs.NTFS().label_format_ok("n" * 128)) - - # all devices are permitted to be passed a label argument of None - # some will ignore it completely - for _k, v in device_formats.items(): - self.assertIsNotNone(v(label=None)) - - class XFSTestCase(fslabeling.CompleteLabelingAsRoot): _fs_class = fs.XFS _invalid_label = "root filesystem" diff --git a/tests/unit_tests/formats_tests/init_test.py b/tests/unit_tests/formats_tests/init_test.py index 6d35920e5..420230056 100644 --- a/tests/unit_tests/formats_tests/init_test.py +++ b/tests/unit_tests/formats_tests/init_test.py @@ -37,3 +37,39 @@ def test_formats_methods(self): # Copy or deepcopy should preserve the id self.assertEqual(ids, [copy.copy(obj).id for obj in objs]) self.assertEqual(ids, [copy.deepcopy(obj).id for obj in objs]) + + +class InitializationTestCase(unittest.TestCase): + + """Test FS object initialization.""" + + def test_labels(self): + """Initialize some filesystems with valid and invalid labels.""" + + # Ext2FS has a maximum length of 16 + self.assertFalse(formats.fs.Ext2FS().label_format_ok("root___filesystem")) + self.assertTrue(formats.fs.Ext2FS().label_format_ok("root__filesystem")) + + # FATFS has a maximum length of 11 + self.assertFalse(formats.fs.FATFS().label_format_ok("rtfilesystem")) + self.assertTrue(formats.fs.FATFS().label_format_ok("rfilesystem")) + + # XFS has a maximum length 12 and does not allow spaces + self.assertFalse(formats.fs.XFS().label_format_ok("root_filesyst")) + self.assertFalse(formats.fs.XFS().label_format_ok("root file")) + self.assertTrue(formats.fs.XFS().label_format_ok("root_filesys")) + + # HFSPlus has a maximum length of 128, minimum length of 1, and does not allow colons + self.assertFalse(formats.fs.HFSPlus().label_format_ok("n" * 129)) + self.assertFalse(formats.fs.HFSPlus().label_format_ok("root:file")) + self.assertFalse(formats.fs.HFSPlus().label_format_ok("")) + self.assertTrue(formats.fs.HFSPlus().label_format_ok("n" * 128)) + + # NTFS has a maximum length of 128 + self.assertFalse(formats.fs.NTFS().label_format_ok("n" * 129)) + self.assertTrue(formats.fs.NTFS().label_format_ok("n" * 128)) + + # all devices are permitted to be passed a label argument of None + # some will ignore it completely + for _k, v in formats.device_formats.items(): + self.assertIsNotNone(v(label=None))