def primary_in_path_contains_only_packages(context, path): check_context_table(context, ["Name", "Epoch", "Version", "Release", "Architecture"]) filepath = os.path.join(context.tempdir_manager.tempdir, path.lstrip('/'), "*-primary.xml.*") primary_filepath = glob.glob(filepath)[0] primary = xml_parse_repodata(primary_filepath, "{%s}package" % ns["pri_ns"], "primary") for name, epoch, version, release, architecture in context.table: nevra = build_nevra(name, epoch, version, release, architecture) found = False for key in primary.keys(): pkg = primary.items[key] if (nevra == pkg.nevra()): del primary.items[key] found = True break if not found: print("primary.xml yet unmatched packages:") for key in primary.keys(): pkg = primary.items[key] print("\t" + build_nevra(pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)) raise AssertionError("Package " + nevra + " not found") if (len(primary.keys()) > 0): print("primary.xml contains additional packages:") for key in primary.keys(): pkg = primary.items[key] print("\t" + build_nevra(pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)) raise AssertionError("Additional packages in primary.xml")
def primary_in_path_doesnt_contain_any_packages(context, path): filepath = os.path.join(context.tempdir_manager.tempdir, path.lstrip('/'), "*-primary.xml.*") primary_filepath = glob.glob(filepath)[0] primary = xml_parse_repodata(primary_filepath, "{%s}package" % ns["pri_ns"], "primary") if (len(primary.keys()) > 0): print("primary.xml contains additional packages:") for key in primary.keys(): pkg = primary.items[key] print("\t" + build_nevra(pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)) raise AssertionError("Additional packages in primary.xml")
def nevra(self): return build_nevra(self.name, self.epoch, self.version, self.release, self.arch)