Beispiel #1
0
def test_dpkg_manager_identify_packages():
    files = ["/sbin/iptables"]
    tracer = DebTracer()
    (packages, unknown_files) = \
        tracer.identify_packages_from_files(files)
    # Make sure that iptables was identified
    assert (not unknown_files), "/sbin/iptables should be identified"
    assert len(packages) == 1
    pkg = packages[0]
    assert pkg.name == 'iptables'
    # Make sure apt_sources are identified, but then we should ask the entire
    # distribution
    distributions = list(tracer.identify_distributions(files))
    assert len(distributions) == 1
    distribution, unknown_files = distributions[0]
    print(json.dumps(attr.asdict(distribution), indent=4))
    assert distribution.apt_sources
    # Make sure both a non-local origin was found
    for o in distribution.apt_sources:
        if o.site:
            # Loop over mandatory attributes
            for a in [
                    "name", "component", "origin", "label", "site",
                    "archive_uri"
            ]:
                assert getattr(o, a), "A non-local origin needs a " + a
            # Note: date and architecture are not mandatory (and not found on
            # travis)
            break
    else:
        assert False, "A non-local origin must be found"
Beispiel #2
0
def test_check_bin_packages():
    # Gather files in /usr/bin and /usr/lib
    files = list_all_files("/usr/bin") + list_all_files("/usr/lib")
    tracer = DebTracer()
    distributions = list(tracer.identify_distributions(files))
    assert len(distributions) == 1
    distribution, unknown_files = distributions[0]
    print(json.dumps(attr.asdict(distribution), indent=4))
    non_local_origins = [o for o in distribution.apt_sources if o.site]
    assert len(non_local_origins) > 0, "A non-local origin must be found"
    for o in non_local_origins:
        # Loop over mandatory attributes
        for a in [
                "name", "component", "origin", "label", "site", "archive_uri"
        ]:
            assert getattr(o, a), "A non-local origin needs a " + a