summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-09-14 20:57:37 +0200
committerZac Medico <zmedico@gentoo.org>2010-09-14 18:09:27 -0700
commitb01d94925297c924365364e82f34e20509130210 (patch)
tree2aa898ea33c0db09dfba4c42413c8df282083948
parent884f96b2ce63596821e30422e773a139f73afec0 (diff)
downloadportage-b01d94925297c924365364e82f34e20509130210.tar.gz
portage-b01d94925297c924365364e82f34e20509130210.tar.bz2
portage-b01d94925297c924365364e82f34e20509130210.zip
Tests: test isvalidatom ::repo syntax support
-rw-r--r--pym/portage/tests/dep/test_isvalidatom.py216
1 files changed, 129 insertions, 87 deletions
diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py
index 8f8ce3e01..173ab0dec 100644
--- a/pym/portage/tests/dep/test_isvalidatom.py
+++ b/pym/portage/tests/dep/test_isvalidatom.py
@@ -1,104 +1,146 @@
-# test_isvalidatom.py -- Portage Unit Testing Functionality
-# Copyright 2006 Gentoo Foundation
+# Copyright 2006-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
from portage.dep import isvalidatom
+class IsValidAtomTestCase(object):
+ def __init__(self, atom, expected, allow_wildcard=False, allow_repo=False):
+ self.atom = atom
+ self.expected = expected
+ self.allow_wildcard = allow_wildcard
+ self.allow_repo = allow_repo
+
class IsValidAtom(TestCase):
- """ A simple testcase for isvalidatom
- """
def testIsValidAtom(self):
- tests = [ ( "sys-apps/portage", True ),
- ( "=sys-apps/portage-2.1", True ),
- ( "=sys-apps/portage-2.1*", True ),
- ( ">=sys-apps/portage-2.1", True ),
- ( "<=sys-apps/portage-2.1", True ),
- ( ">sys-apps/portage-2.1", True ),
- ( "<sys-apps/portage-2.1", True ),
- ( "~sys-apps/portage-2.1", True ),
- ( "sys-apps/portage:foo", True ),
- ( "sys-apps/portage-2.1:foo", False ),
- ( "sys-apps/portage-2.1:", False ),
- ( "sys-apps/portage-2.1:[foo]", False ),
- ( "=sys-apps/portage-2.2*:foo[bar?,!baz?,!doc=,build=]", True ),
- ( "=sys-apps/portage-2.2*:foo[doc?]", True ),
- ( "=sys-apps/portage-2.2*:foo[!doc?]", True ),
- ( "=sys-apps/portage-2.2*:foo[doc=]", True ),
- ( "=sys-apps/portage-2.2*:foo[!doc=]", True ),
- ( "=sys-apps/portage-2.2*:foo[!doc]", False ),
- ( "=sys-apps/portage-2.2*:foo[!-doc]", False ),
- ( "=sys-apps/portage-2.2*:foo[!-doc=]", False ),
- ( "=sys-apps/portage-2.2*:foo[!-doc?]", False ),
- ( "=sys-apps/portage-2.2*:foo[-doc?]", False ),
- ( "=sys-apps/portage-2.2*:foo[-doc=]", False ),
- ( "=sys-apps/portage-2.2*:foo[-doc!=]", False ),
- ( "=sys-apps/portage-2.2*:foo[-doc=]", False ),
- ( "=sys-apps/portage-2.2*:foo[bar][-baz][doc?][!build?]", False ),
- ( "=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?]", True ),
- ( "=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?,]", False ),
- ( "=sys-apps/portage-2.2*:foo[,bar,-baz,doc?,!build?]", False ),
- ( "=sys-apps/portage-2.2*:foo[bar,-baz][doc?,!build?]", False ),
- ( "=sys-apps/portage-2.2*:foo[bar][doc,build]", False ),
- ( ">~cate-gory/foo-1.0", False ),
- ( ">~category/foo-1.0", False ),
- ( "<~category/foo-1.0", False ),
- ( "###cat/foo-1.0", False ),
- ( "~sys-apps/portage", False ),
- ( "portage", False ),
- ( "=portage", False ),
- ( ">=portage-2.1", False ),
- ( "~portage-2.1", False ),
- ( "=portage-2.1*", False ),
- ( "null/portage", True ),
- ( "null/portage*:0", False ),
- ( ">=null/portage-2.1", True ),
- ( ">=null/portage", False ),
- ( ">null/portage", False ),
- ( "=null/portage*", False ),
- ( "=null/portage", False ),
- ( "~null/portage", False ),
- ( "<=null/portage", False ),
- ( "<null/portage", False ),
- ( "~null/portage-2.1", True ),
- ( "=null/portage-2.1*", True ),
- ( "null/portage-2.1*", False ),
- ( "app-doc/php-docs-20071125", False),
- ( "app-doc/php-docs-20071125-r2", False),
- ( "=foo/bar-1-r1-1-r1", False ),
- ( "foo/-z-1", False ),
+ test_cases = (
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.1", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.1*", True),
+ IsValidAtomTestCase(">=sys-apps/portage-2.1", True),
+ IsValidAtomTestCase("<=sys-apps/portage-2.1", True),
+ IsValidAtomTestCase(">sys-apps/portage-2.1", True),
+ IsValidAtomTestCase("<sys-apps/portage-2.1", True),
+ IsValidAtomTestCase("~sys-apps/portage-2.1", True),
+ IsValidAtomTestCase("sys-apps/portage:foo", True),
+ IsValidAtomTestCase("sys-apps/portage-2.1:foo", False),
+ IsValidAtomTestCase( "sys-apps/portage-2.1:", False),
+ IsValidAtomTestCase("sys-apps/portage-2.1:", False),
+ IsValidAtomTestCase("sys-apps/portage-2.1:[foo]", False),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+ IsValidAtomTestCase("sys-apps/portage", True),
+
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar?,!baz?,!doc=,build=]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[doc?]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!doc?]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[doc=]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!doc=]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!doc]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!-doc]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!-doc=]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[!-doc?]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[-doc?]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[-doc=]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[-doc!=]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[-doc=]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar][-baz][doc?][!build?]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?]", True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?,]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[,bar,-baz,doc?,!build?]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar,-baz][doc?,!build?]", False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo[bar][doc,build]", False),
+ IsValidAtomTestCase(">~cate-gory/foo-1.0", False),
+ IsValidAtomTestCase(">~category/foo-1.0", False),
+ IsValidAtomTestCase("<~category/foo-1.0", False),
+ IsValidAtomTestCase("###cat/foo-1.0", False),
+ IsValidAtomTestCase("~sys-apps/portage", False),
+ IsValidAtomTestCase("portage", False),
+ IsValidAtomTestCase("=portage", False),
+ IsValidAtomTestCase(">=portage-2.1", False),
+ IsValidAtomTestCase("~portage-2.1", False),
+ IsValidAtomTestCase("=portage-2.1*", False),
+ IsValidAtomTestCase("null/portage", True),
+ IsValidAtomTestCase("null/portage*:0", False),
+ IsValidAtomTestCase(">=null/portage-2.1", True),
+ IsValidAtomTestCase(">=null/portage", False),
+ IsValidAtomTestCase(">null/portage", False),
+ IsValidAtomTestCase("=null/portage*", False),
+ IsValidAtomTestCase("=null/portage", False),
+ IsValidAtomTestCase("~null/portage", False),
+ IsValidAtomTestCase("<=null/portage", False),
+ IsValidAtomTestCase("<null/portage", False),
+ IsValidAtomTestCase("~null/portage-2.1", True),
+ IsValidAtomTestCase("=null/portage-2.1*", True),
+ IsValidAtomTestCase("null/portage-2.1*", False),
+ IsValidAtomTestCase("app-doc/php-docs-20071125", False),
+ IsValidAtomTestCase("app-doc/php-docs-20071125-r2", False),
+ IsValidAtomTestCase("=foo/bar-1-r1-1-r1", False),
+ IsValidAtomTestCase("foo/-z-1", False),
# These are invalid because pkg name must not end in hyphen
# followed by numbers
- ( "=foo/bar-1-r1-1-r1", False ),
- ( "=foo/bar-123-1", False ),
- ( "=foo/bar-123-1*", False ),
- ( "foo/bar-123", False ),
- ( "=foo/bar-123-1-r1", False ),
- ( "=foo/bar-123-1-r1*", False ),
- ( "foo/bar-123-r1", False ),
- ( "foo/bar-1", False ),
+ IsValidAtomTestCase("=foo/bar-1-r1-1-r1", False),
+ IsValidAtomTestCase("=foo/bar-123-1", False),
+ IsValidAtomTestCase("=foo/bar-123-1*", False),
+ IsValidAtomTestCase("foo/bar-123", False),
+ IsValidAtomTestCase("=foo/bar-123-1-r1", False),
+ IsValidAtomTestCase("=foo/bar-123-1-r1*", False),
+ IsValidAtomTestCase("foo/bar-123-r1", False),
+ IsValidAtomTestCase("foo/bar-1", False),
+
+ IsValidAtomTestCase("=foo/bar--baz-1-r1", True),
+ IsValidAtomTestCase("=foo/bar-baz--1-r1", True),
+ IsValidAtomTestCase("=foo/bar-baz---1-r1", True),
+ IsValidAtomTestCase("=foo/bar-baz---1", True),
+ IsValidAtomTestCase("=foo/bar-baz-1--r1", False),
+ IsValidAtomTestCase("games-strategy/ufo2000", True),
+ IsValidAtomTestCase("~games-strategy/ufo2000-0.1", True),
+ IsValidAtomTestCase("=media-libs/x264-20060810", True),
+ IsValidAtomTestCase("foo/b", True),
+ IsValidAtomTestCase("app-text/7plus", True),
+ IsValidAtomTestCase("foo/666", True),
+ IsValidAtomTestCase("=dev-libs/poppler-qt3-0.11*", True),
+
+ #Testing atoms with repositories
+ IsValidAtomTestCase("sys-apps/portage::repo_123-name", True, allow_repo=True),
+ IsValidAtomTestCase("=sys-apps/portage-2.1::repo", True, allow_repo=True),
+ IsValidAtomTestCase("=sys-apps/portage-2.1*::repo", True, allow_repo=True),
+ IsValidAtomTestCase("sys-apps/portage:foo::repo", True, allow_repo=True),
+ IsValidAtomTestCase("sys-apps/portage-2.1:foo::repo", False, allow_repo=True),
+ IsValidAtomTestCase("sys-apps/portage-2.1:::repo", False, allow_repo=True),
+ IsValidAtomTestCase("sys-apps/portage-2.1:::repo[foo]", False, allow_repo=True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo::repo[bar?,!baz?,!doc=,build=]", True, allow_repo=True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo::repo[doc?]", True, allow_repo=True),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo::repo[!doc]", False, allow_repo=True),
+ IsValidAtomTestCase("###cat/foo-1.0::repo", False, allow_repo=True),
+ IsValidAtomTestCase("~sys-apps/portage::repo", False, allow_repo=True),
+ IsValidAtomTestCase("portage::repo", False, allow_repo=True),
+ IsValidAtomTestCase("=portage::repo", False, allow_repo=True),
+ IsValidAtomTestCase("null/portage::repo", True, allow_repo=True),
+ IsValidAtomTestCase("app-doc/php-docs-20071125::repo", False, allow_repo=True),
+ IsValidAtomTestCase("=foo/bar-1-r1-1-r1::repo", False, allow_repo=True),
- ( "=foo/bar--baz-1-r1", True ),
- ( "=foo/bar-baz--1-r1", True ),
- ( "=foo/bar-baz---1-r1", True ),
- ( "=foo/bar-baz---1", True ),
- ( "=foo/bar-baz-1--r1", False ),
- ( "games-strategy/ufo2000", True ),
- ( "~games-strategy/ufo2000-0.1", True ),
- ( "=media-libs/x264-20060810", True ),
- ( "foo/b", True ),
- ( "app-text/7plus", True ),
- ( "foo/666", True ),
- ( "=dev-libs/poppler-qt3-0.11*", True ),
- ]
+ IsValidAtomTestCase("sys-apps/portage::repo_123-name", False, allow_repo=False),
+ IsValidAtomTestCase("=sys-apps/portage-2.1::repo", False, allow_repo=False),
+ IsValidAtomTestCase("=sys-apps/portage-2.1*::repo", False, allow_repo=False),
+ IsValidAtomTestCase("sys-apps/portage:foo::repo", False, allow_repo=False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo::repo[bar?,!baz?,!doc=,build=]", False, allow_repo=False),
+ IsValidAtomTestCase("=sys-apps/portage-2.2*:foo::repo[doc?]", False, allow_repo=False),
+ IsValidAtomTestCase("null/portage::repo", False, allow_repo=False),
+ )
- for test in tests:
- if test[1]:
+ for test_case in test_cases:
+ if test_case.expected:
atom_type = "valid"
else:
atom_type = "invalid"
- self.assertEqual( bool(isvalidatom( test[0] )), test[1],
- msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) )
+ self.assertEqual( bool(isvalidatom(test_case.atom, allow_wildcard=test_case.allow_wildcard, \
+ allow_repo=test_case.allow_repo)), test_case.expected,
+ msg="isvalidatom(%s) != %s" % ( test_case.atom, test_case.expected ) )