Exemple #1
0
def test_from_json():
    rpms = InstalledRpms(context_wrap(RPMS_JSON))
    assert isinstance(rpms.get_max("log4j").source, InstalledRpm)
    assert len(rpms.packages) == len(RPMS_JSON.splitlines())
    assert rpms.get_max("log4j").source.name == "log4j"
    assert rpms.get_max("util-linux").epoch == '0'
    assert rpms.get_max("jboss-servlet-3.0-api").redhat_signed

    assert rpms.newest('libnl').vendor == '(none)'
    assert rpms.newest('crash').vendor == 'Red Hat, Inc.'
    assert rpms.newest('log4j').vendor is None
def test_from_line():
    rpms = InstalledRpms(context_wrap(RPMS_LINE))
    assert rpms.get_max("ConsoleKit").arch == 'x86_64'
    assert rpms.get_max("kernel").version == '2.6.32'
    assert rpms.get_max("yum").release == '69.el6'
    assert rpms.get_max("tftp-server").version == '5.2'
    assert rpms.get_max("yum").package == "yum-3.2.29-69.el6"
    assert rpms.get_max("tftp-server").redhat_signed is None
    assert rpms.get_max("yum").redhat_signed
    assert rpms.corrupt is False

    assert rpms.newest('BESAgent').vendor == 'IBM Corp.'
    assert rpms.newest('yum').vendor == 'Red Hat, Inc.'
    assert rpms.newest('kernel').vendor is None
def test_corrupt_db():
    rpms = InstalledRpms(context_wrap(ERROR_DB))
    assert rpms.corrupt is True
    assert "yum-security" in rpms.packages
    assert "yum-security" in rpms

    rpms = InstalledRpms(context_wrap(ERROR_DB_NO_PKG))
    assert rpms.corrupt is True
    assert not rpms.packages
    assert "kernel" not in rpms
    assert "kernel" not in rpms.packages
    assert rpms.newest("kernel") is None
    assert rpms.oldest("kernel") is None