def test_it(self): # single version, shouldn't yield. check = drop_keys(misc.Options((("arches", ["x86", "amd64"]), ))) self.assertNoReport(check, [self.mk_pkg('1')]) reports = self.assertReports( check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("2")]) self.assertEqual(set(chain.from_iterable(x.arches for x in reports)), set(["x86", "amd64"])) # ensure it limits it's self to just the arches we care about # check unstable at the same time; # finally, check '-' handling; if x86 -> -x86, that's valid. self.assertNoReport(check, [ self.mk_pkg("1", "x86 ~amd64 ppc"), self.mk_pkg("2", "~amd64 x86"), self.mk_pkg("3", "-amd64 x86") ]) # ensure it doesn't flag live ebuilds self.assertNoReport( check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("9999", "")]) self.assertNoReport( check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("99999999", "")]) self.assertNoReport( check, [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("1.0.0.9999", "")])
def test_it(self): mk_pkg = self.mk_pkg check = ImlateReport( misc.Options(selected_arches=("x86", "ppc", "amd64"), arches=("x86", "ppc", "amd64"), source_arches=("x86", "ppc", "amd64")), None) self.assertNoReport( check, [mk_pkg(str(x), "~x86 ~amd64") for x in xrange(10)]) # assert single 0.9/0.8 report = self.assertReports( check, [mk_pkg("0.8", "~x86"), mk_pkg("0.9", "~x86 amd64")]) self.assertEqual(len(report), 1) self.assertEqual(report[0].stable, ("amd64", )) self.assertEqual(report[0].version, "0.9") # insert a 0.7 in; it should not show. # additionally, insert an arch we don't care about... report = self.assertReports(check, [ mk_pkg("0.7", "~x86"), mk_pkg("0.8", "~x86 ~foo"), mk_pkg("0.9", "~x86 amd64"), mk_pkg("0.10", "foo") ]) self.assertEqual(len(report), 1) self.assertEqual(report[0].stable, ("amd64", )) self.assertEqual(report[0].version, "0.9")
def test_it(self): now = time.time() mk_pkg = self.mk_pkg check = StaleUnstableReport( misc.Options(selected_arches=("x86", "ppc", "amd64"), arches=("x86", "ppc", "amd64")), None) check.start() old = now - (30 * 24 * 3600) # a current one self.assertNoReport(check, mk_pkg("1.0", "x86", now)) # an outdated, but stable one self.assertNoReport(check, mk_pkg("1.0", "x86", old)) # an outdated, partly unstable one self.assertReport(check, mk_pkg("1.0", "~amd64 x86", old)) # an outdated, fully unstable one self.assertReport(check, mk_pkg("1.0", "~amd64 ~x86", old)) # ensure it reports only specified arches. report = self.assertReport( check, mk_pkg("1.0", "~amd64 ~x86 ~asdfasdfasdf", old)) self.assertEqual(report.keywords, tuple(sorted(["~amd64", "~x86"])))
def test_it(self): # single version, shouldn't yield. check = vuln_report( misc.Options(glsa_location=self.dir, glsa_enabled=True)) with open(pjoin(self.dir, "glsa-200611-01.xml"), "w") as f: f.write(mk_glsa(("dev-util/diffball", ([], [">0.7"])))) with open(pjoin(self.dir, "glsa-200611-02.xml"), "w") as f: f.write(mk_glsa(("dev-util/diffball", ([], ["~>=0.5-r3"])))) check.start() self.assertNoReport(check, self.mk_pkg("0.5.1")) r = self.assertReports(check, self.mk_pkg("0.5-r5")) self.assertEqual(len(r), 1) self.assertEqual( (r[0].category, r[0].package, r[0].version), ("dev-util", "diffball", "0.5-r5")) self.assertReports(check, self.mk_pkg("1.0")) self.assertNoReport(check, self.mk_pkg("5", "dev-util/diffball2"))
def get_options(self, **kwds): repo_base = tempfile.mkdtemp(dir=self.dir) base = pjoin(repo_base, 'profiles') os.mkdir(base) fileutils.write_file( pjoin(base, "arch.list"), 'w', "\n".join(kwds.pop("arches", ("x86", "ppc", "amd64")))) fileutils.write_file( pjoin(base, "use.desc"), "w", "\n".join("%s - %s" % (x, x) for x in kwds.pop("use_desc", ("foo", "bar")))) fileutils.write_file(pjoin(base, 'repo_name'), 'w', 'monkeys') os.mkdir(pjoin(repo_base, 'metadata')) fileutils.write_file(pjoin(repo_base, 'metadata', 'layout.conf'), 'w', "masters = ") kwds['target_repo'] = repository._UnconfiguredTree(repo_base) return misc.Options(**kwds)