Ejemplo n.º 1
0
def test_lsblockpairs_no_type():
    # LSBlock will always have a type column because of the regular expression
    # match; LSBlockPairs is looser about the data available.
    with pytest.raises(ParseException) as exc:
        blocks = lsblk.LSBlockPairs(context_wrap(LSBLOCKPAIRS_NO_TYPE_DATA))
        assert repr(blocks.rows[0]) is None
    assert 'TYPE not found in LsBlockPairs line' in str(exc)
Ejemplo n.º 2
0
def test_lsblockpairs_no_translate():
    # LSBlockPairs translates 'RM' to 'REMOVABLE' and 'RO' to 'READ_ONLY';
    # normally every block device will have these two attributes.  But if for
    # some reason it doesn't, we want to make sure that the code still works
    # correctly.  This is mainly for code coverage testing.
    blocks = lsblk.LSBlockPairs(context_wrap(LSBLOCKPAIRS_NO_TRANSLATE_DATA))
    assert 'sr0' in blocks.device_data
    assert not hasattr(blocks.device_data['sr0'], 'removable')
    assert not hasattr(blocks.device_data['sr0'], 'read_only')
Ejemplo n.º 3
0
def test_lsblk_po():
    results = lsblk.LSBlockPairs(context_wrap(LSBLK_EXT_DATA))
    assert results is not None
    assert len(results) == 7
    sda1 = None
    for result in results:
        if result.name == 'sda1':
            sda1 = result
    assert sda1 is not None
    assert sda1.alignment == "0"
    assert sda1.disc_aln == "0"
    assert sda1.disc_gran == "0B"
    assert sda1.disc_max == "0B"
    assert sda1.disc_zero == "0"
    assert sda1.fstype == "ext4"
    assert sda1.group == "disk"
    assert sda1.kname == "sda1"
    assert 'LABEL' not in sda1
    assert sda1.log_sec == "512"
    assert sda1.maj_min == "8:1"
    assert sda1.min_io == "512"
    assert sda1.mode == "brw-rw----"
    assert 'MODEL' not in sda1
    assert sda1.mountpoint == "/boot"
    assert sda1.name == "sda1"
    assert sda1.opt_io == "0"
    assert sda1.owner == "root"
    assert sda1.phy_sec == "512"
    assert sda1.ra == "128"
    assert sda1.removable is False
    assert sda1.read_only is False
    assert sda1.rota == "1"
    assert sda1.rq_size == "128"
    assert sda1.sched == "cfq"
    assert sda1.size == "500M"
    assert 'STATE' not in sda1
    assert sda1.type == "part"
    assert sda1.uuid == "c7c4c016-8b00-4ded-bffb-5cc4719b7d45"
Ejemplo n.º 4
0
def test_lsblockpairs_invalid_option():
    with pytest.raises(ParseException) as ex:
        lsblk.LSBlockPairs(context_wrap(LSBLK_INVALID_OPTION))
    assert "/bin/lsblk: invalid option" in str(ex)
Ejemplo n.º 5
0
def test_lsblockpairs_failed():
    blocks = lsblk.LSBlockPairs(context_wrap(LSBLK_EXT_DATA_FAILED_PATH))
    assert "dm-0" in blocks.failed_device_paths
    assert "dm-1" in blocks.failed_device_paths