def test_fs_by_mount(self): expected_fs = objects.FileSystem('d', mount='mount') self.p_scheme.fss.append(expected_fs) self.p_scheme.fss.append(objects.FileSystem('w_d', mount='wrong_mount')) actual_fs = self.p_scheme.fs_by_mount('mount') self.assertEqual(expected_fs, actual_fs)
def test_md_by_mount(self): self.assertEqual(0, len(self.p_scheme.mds)) self.assertEqual(0, len(self.p_scheme.fss)) expected_md = objects.MultipleDevice('name', 'level') expected_fs = objects.FileSystem('name', mount='mount') self.p_scheme.mds.append(expected_md) self.p_scheme.fss.append(expected_fs) self.p_scheme.fss.append(objects.FileSystem('wrong_name', mount='wrong_mount')) self.assertEqual(expected_md, self.p_scheme.md_by_mount('mount'))
def test_md_attach_by_mount_md_exists(self): self.assertEqual(0, len(self.p_scheme.mds)) self.assertEqual(0, len(self.p_scheme.fss)) expected_md = objects.MultipleDevice('name', 'level') expected_fs = objects.FileSystem('name', mount='mount') self.p_scheme.mds.append(expected_md) self.p_scheme.fss.append(expected_fs) actual_md = self.p_scheme.md_attach_by_mount('device', 'mount') self.assertIn('device', actual_md.devices) self.assertEqual(expected_md, actual_md)
def test_conversion(self): fs = objects.FileSystem( device='some-device', mount='/mount', fs_type='type', fs_options='some-option', fs_label='some-label', ) serialized = fs.to_dict() assert serialized == { 'device': 'some-device', 'mount': '/mount', 'fs_type': 'type', 'fs_options': 'some-option', 'fs_label': 'some-label', 'keep_data': False, 'fstab_enabled': True, 'fstab_options': 'defaults', 'os_id': [] } new_fs = objects.FileSystem.from_dict(serialized) assert serialized == new_fs.to_dict()
def test_fs_by_device(self): expected_fs = objects.FileSystem('device') self.p_scheme.fss.append(expected_fs) self.p_scheme.fss.append(objects.FileSystem('wrong_device')) actual_fs = self.p_scheme.fs_by_device('device') self.assertEqual(expected_fs, actual_fs)