Example #1
0
def test_loop_support():
    output = 'NAME="/dev/loop0" SIZE="10M" TYPE="loop" MOUNTPOINT="" PARTTYPE="" FSTYPE="" MODEL=""'
    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(output)
    assert len(disks) == 1
Example #2
0
def test_do_not_show_squashfs():

    output = 'NAME="/dev/loop1" SIZE="41.1M" TYPE="loop" MOUNTPOINT="/snap/platform/180821" PARTTYPE="" FSTYPE="squashfs" MODEL=""'

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(output)

    assert len(disks) == 0
Example #3
0
def test_empty_disk():

    output = 'NAME="/dev/sda" SIZE="3.7G" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="" MODEL="BLANK DISK"'

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(output)

    assert len(disks[0].partitions) == 0
Example #4
0
def test_list():

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(default_output)
    assert len(disks) == 5
    assert len(disks[0].partitions) == 4
    assert disks[1].partitions[2].mount_point == '/opt/disk/external'
    assert len(disks[1].partitions) == 3
Example #5
0
def test_default_empty_disk_name():
    lsblk_output = 'NAME="/dev/sdb" SIZE="14.4G" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="" MODEL=""\n'
    lsblk_output += 'NAME="/dev/sdb1" SIZE="14.4G" TYPE="part" MOUNTPOINT="" PARTTYPE="0x83" FSTYPE="ext4" MODEL=""\n'
    lsblk_output += 'NAME="/dev/sdb2" SIZE="41.8M" TYPE="part" MOUNTPOINT="" PARTTYPE="0xc" FSTYPE="vfat" MODEL=""'

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(lsblk_output)
    assert disks[0].name == 'Disk'
Example #6
0
def test_do_not_show_disks_with_root_partition():
    lsblk_output = 'NAME="/dev/sdb" SIZE="14.4G" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="" MODEL=""\n'
    lsblk_output += 'NAME="/dev/sdb1" SIZE="14.4G" TYPE="part" MOUNTPOINT="/" PARTTYPE="0x83" FSTYPE="ext4" MODEL=""\n'
    lsblk_output += 'NAME="/dev/sdb2" SIZE="41.8M" TYPE="part" MOUNTPOINT="" PARTTYPE="0xc" FSTYPE="vfat" MODEL=""'

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(lsblk_output)

    assert len(disks) == 0
Example #7
0
def test_list():

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(default_output)
    assert len(disks) == 5
    disk = [d for d in disks if d.device == '/dev/sda'][0]
    assert len(disk.partitions) == 4

    disk = [d for d in disks if d.device == '/dev/sdb'][0]
    assert disk.partitions[2].mount_point == '/opt/disk/external'
    assert len(disk.partitions) == 3
Example #8
0
def test_raid():
    raid_output = '''NAME="/dev/sda" SIZE="1.8T" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="linux_raid_member" MODEL="WDC WD20EFRX-68E"
NAME="/dev/sdb" SIZE="1.8T" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="linux_raid_member" MODEL="WDC WD20EFRX-68E"
NAME="/dev/sdc" SIZE="1.8T" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="linux_raid_member" MODEL="WDC WD20EFRX-68E"
NAME="/dev/sdd" SIZE="1.8T" TYPE="disk" MOUNTPOINT="" PARTTYPE="" FSTYPE="linux_raid_member" MODEL="WDC WD20EFRX-68E"
NAME="/dev/md0" SIZE="3.7T" TYPE="raid10" MOUNTPOINT="/mnt/md0" PARTTYPE="" FSTYPE="ext4" MODEL=""
NAME="/dev/md0" SIZE="3.7T" TYPE="raid10" MOUNTPOINT="/mnt/md0" PARTTYPE="" FSTYPE="ext4" MODEL=""
NAME="/dev/md0" SIZE="3.7T" TYPE="raid10" MOUNTPOINT="/mnt/md0" PARTTYPE="" FSTYPE="ext4" MODEL=""
NAME="/dev/md0" SIZE="3.7T" TYPE="raid10" MOUNTPOINT="/mnt/md0" PARTTYPE="" FSTYPE="ext4" MODEL=""'''

    platform_config = PlatformConfig(CONFIG_DIR)
    lsblk = Lsblk(platform_config, PathChecker(platform_config))

    disks = lsblk.available_disks(raid_output)
    assert len(disks) == 1
    assert len(disks[0].partitions) == 1
    assert disks[0].partitions[0].mount_point == '/mnt/md0'