def test_intersects(self): for this, that, result in [ ("cat/pkg", "pkg/cat", False), ("cat/pkg", "cat/pkg", True), ("cat/pkg:1", "cat/pkg:1", True), ("cat/pkg:1", "cat/pkg:2", False), ("cat/pkg:1", "cat/pkg[foo]", True), ("cat/pkg[foo]", "cat/pkg[-bar]", True), ("cat/pkg[foo]", "cat/pkg[-foo]", False), (">cat/pkg-3", ">cat/pkg-1", True), (">cat/pkg-3", "<cat/pkg-3", False), (">=cat/pkg-3", "<cat/pkg-3", False), (">cat/pkg-2", "=cat/pkg-2*", True), # Portage vercmp disagrees with this one: # ('<cat/pkg-2_alpha1', '=cat/pkg-2*', True), ("=cat/pkg-2", "=cat/pkg-2", True), ("=cat/pkg-3", "=cat/pkg-2", False), ("=cat/pkg-2", ">cat/pkg-2", False), ("=cat/pkg-2", ">=cat/pkg-2", True), ("~cat/pkg-2", "~cat/pkg-2", True), ("~cat/pkg-2", "~cat/pkg-2.1", False), ("=cat/pkg-2*", "=cat/pkg-2.3*", True), (">cat/pkg-2.4", "=cat/pkg-2*", True), ("<cat/pkg-2.4", "=cat/pkg-2*", True), ("<cat/pkg-1", "=cat/pkg-2*", False), ("~cat/pkg-2", ">cat/pkg-2-r1", True), ("~cat/pkg-2", "<=cat/pkg-2", True), ("=cat/pkg-2-r2*", "<=cat/pkg-2-r20", True), ("=cat/pkg-2-r2*", "<cat/pkg-2-r20", True), ("=cat/pkg-2-r2*", "<=cat/pkg-2-r2", True), ("~cat/pkg-2", "<cat/pkg-2", False), ("=cat/pkg-1-r10*", "~cat/pkg-1", True), ("=cat/pkg-1-r1*", "<cat/pkg-1-r1", False), ("=cat/pkg-1*", ">cat/pkg-2", False), (">=cat/pkg-8.4", "=cat/pkg-8.3.4*", False), ("cat/pkg::gentoo", "cat/pkg", True), ("cat/pkg::gentoo", "cat/pkg::foo", False), ("=sys-devel/gcc-4.1.1-r3", "=sys-devel/gcc-3.3*", False), ("=sys-libs/db-4*", "~sys-libs/db-4.3.29", True), ]: this_atom = Atom(this) that_atom = Atom(that) self.assertEqual( result, this_atom.intersects(that_atom), "%s intersecting %s should be %s" % (this, that, result), ) self.assertEqual( result, that_atom.intersects(this_atom), "%s intersecting %s should be %s" % (that, this, result), )
def test_intersects(self): for this, that, result in [ ('cat/pkg', 'pkg/cat', False), ('cat/pkg', 'cat/pkg', True), ('cat/pkg:1', 'cat/pkg:1', True), ('cat/pkg:1', 'cat/pkg:2', False), ('cat/pkg:1', 'cat/pkg[foo]', True), ('cat/pkg[foo]', 'cat/pkg[-bar]', True), ('cat/pkg[foo]', 'cat/pkg[-foo]', False), ('>cat/pkg-3', '>cat/pkg-1', True), ('>cat/pkg-3', '<cat/pkg-3', False), ('>=cat/pkg-3', '<cat/pkg-3', False), ('>cat/pkg-2', '=cat/pkg-2*', True), # Portage vercmp disagrees with this one: #('<cat/pkg-2_alpha1', '=cat/pkg-2*', True), ('=cat/pkg-2', '=cat/pkg-2', True), ('=cat/pkg-3', '=cat/pkg-2', False), ('=cat/pkg-2', '>cat/pkg-2', False), ('=cat/pkg-2', '>=cat/pkg-2', True), ('~cat/pkg-2', '~cat/pkg-2', True), ('~cat/pkg-2', '~cat/pkg-2.1', False), ('=cat/pkg-2*', '=cat/pkg-2.3*', True), ('>cat/pkg-2.4', '=cat/pkg-2*', True), ('<cat/pkg-2.4', '=cat/pkg-2*', True), ('<cat/pkg-1', '=cat/pkg-2*', False), ('~cat/pkg-2', '>cat/pkg-2-r1', True), ('~cat/pkg-2', '<=cat/pkg-2', True), ('=cat/pkg-2-r2*', '<=cat/pkg-2-r20', True), ('=cat/pkg-2-r2*', '<cat/pkg-2-r20', True), ('=cat/pkg-2-r2*', '<=cat/pkg-2-r2', True), ('~cat/pkg-2', '<cat/pkg-2', False), ('=cat/pkg-1-r10*', '~cat/pkg-1', True), ('=cat/pkg-1-r1*', '<cat/pkg-1-r1', False), ('=cat/pkg-1*', '>cat/pkg-2', False), ('>=cat/pkg-8.4', '=cat/pkg-8.3.4*', False), # Repos not yet supported by Portage #('cat/pkg::gentoo', 'cat/pkg', True), #('cat/pkg::gentoo', 'cat/pkg::foo', False), ('=sys-devel/gcc-4.1.1-r3', '=sys-devel/gcc-3.3*', False), ('=sys-libs/db-4*', '~sys-libs/db-4.3.29', True), ]: this_atom = Atom(this) that_atom = Atom(that) self.assertEqual( result, this_atom.intersects(that_atom), '%s intersecting %s should be %s' % (this, that, result)) self.assertEqual( result, that_atom.intersects(this_atom), '%s intersecting %s should be %s' % (that, this, result))
def entries_matching_atom(self, atom): """Return entries whose header versions match atom's version. @type atom: L{gentoolkit.atom.Atom} or str @param atom: a atom to find matching entries against @rtype: list @return: entries matching atom @raise errors.GentoolkitInvalidAtom: if atom is a string and malformed """ result = [] if not isinstance(atom, Atom): atom = Atom(atom) for entry_set in self.indexed_entries: i, entry = entry_set # VersionMatch doesn't store .cp, so we'll force it to match here: i.cp = atom.cp if atom.intersects(i): result.append(entry) return result
def test_intersects_nameonly(self): atom = Atom("cat/pkg") self.assertTrue(atom.intersects(CPV("pkg"))) self.assertFalse(atom.intersects(CPV("other"))) self.assertFalse(atom.intersects(CPV("dkg")))
def test_intersects_nameonly(self): atom = Atom('cat/pkg') self.assertTrue(atom.intersects(CPV('pkg'))) self.assertFalse(atom.intersects(CPV('other'))) self.assertFalse(atom.intersects(CPV('dkg')))