Skip to content

Commit

Permalink
Merge pull request #5876 from adamkankovsky/blivet-device-part-type-name
Browse files Browse the repository at this point in the history
Take partition label from blivet
  • Loading branch information
KKoukiou authored Sep 25, 2024
2 parents 039517b + 76b8556 commit 86f5c01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyanaconda/modules/common/structures/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def attrs(self) -> Dict[Str, Str]:
path-id
Attributes for partitions:
partition-label
partition-type-name
:return: a dictionary of attributes
"""
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/storage/devicetree/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _set_device_data(self, device, data):
data.attrs["uuid"] = self._get_attribute(device, "uuid")

if isinstance(device, PartitionDevice):
data.attrs["partition-label"] = self._get_attribute(device.parted_partition, "name")
data.attrs["partition-type-name"] = self._get_attribute(device, "part_type_name")

def _set_device_data_dasd(self, device, data):
"""Set data for a DASD device."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from pyanaconda.modules.storage.devicetree.rescue import FindExistingSystemsTask, \
MountExistingSystemTask
from pyanaconda.modules.storage.devicetree.root import Root
from parted import PARTITION_NORMAL


class DeviceTreeInterfaceTestCase(unittest.TestCase):
Expand Down Expand Up @@ -357,19 +356,15 @@ def test_get_parted_device_data(self):
size=Size("500 MiB"),
fmt=get_format("ext4", exists=True)
)
attrs = {
'type': PARTITION_NORMAL,
'getLength.return_value': int(sda1.size),
'getFlag.return_value': 0,
'name': "Microsoft reserved partition",
'number': 1
}
sda1._parted_partition = Mock()
sda1._parted_partition.configure_mock(**attrs)
self._add_device(sda1)

data = self.interface.GetDeviceData("dev1")
assert data['attrs']['partition-label'] == "Microsoft reserved partition"
with patch.object(PartitionDevice,
'part_type_name',
new_callable=PropertyMock) as mock_part_type_name:
mock_part_type_name.return_value = "Microsoft reserved partition"

data = self.interface.GetDeviceData("dev1")
assert data['attrs']['partition-type-name'] == "Microsoft reserved partition"

def test_get_format_data(self):
"""Test GetFormatData."""
Expand Down

0 comments on commit 86f5c01

Please sign in to comment.