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"
def test_utf8_file(): files = [ u"/usr/share/ca-certificates/mozilla/" u"TÜBİTAK_UEKAE_Kök_Sertifika_Hizmet_Sağlayıcısı_-_Sürüm_3.crt" ] manager = DebTracer() # Simple sanity check that the pipeline works with utf-8 (packages, unknown_files) = \ manager.identify_packages_from_files(files) # Print for manual debugging pprint(unknown_files) pprint(packages) # If the file exists, it should be in ca-certificates if os.path.isfile(files[0]): assert packages[0].name == "ca-certificates" else: # Otherwise just make sure we didn't throw an exception assert True