Ejemplo n.º 1
0
def _get_mount_points(
        device_data: system_profiler.USBDevice) -> Tuple[pathlib.Path, ...]:
    """Returns mount points for a given device, empty list if device has no mount points."""
    storage_identifiers = [
        media["bsd_name"] for media in device_data.get("Media", [])
        if "bsd_name" in media
    ]
    mount_points = []
    for storage_identifier in storage_identifiers:
        mount_point = diskutil.get_mount_point(storage_identifier)
        if mount_point:
            mount_points.append(pathlib.Path(mount_point))
        else:
            logging.debug(
                f"Couldn't determine mount point for device id: {storage_identifier}."
            )
    return tuple(mount_points)
Ejemplo n.º 2
0
    def test_returns_none_if_no_mountpoint(self, get_all_external_volumes_data):
        get_all_external_volumes_data.return_value = []

        self.assertIsNone(get_mount_point("disk123"), None)
Ejemplo n.º 3
0
    def test_handles_partial_data(self, get_all_external_volumes_data):
        get_all_external_volumes_data.return_value = [{"DeviceIdentifier": "disk4"}]

        self.assertIsNone(get_mount_point("disk4"), None)
Ejemplo n.º 4
0
    def test_returns_mountpoint_if_avaiable(self, get_all_external_volumes_data):
        get_all_external_volumes_data.return_value = [{"DeviceIdentifier": "disk123", "MountPoint": "/here"}]

        self.assertEqual(get_mount_point("disk123"), "/here")