diff options
-rw-r--r-- | tests/portage/dep/test_dep_getslot.py | 18 | ||||
-rw-r--r-- | tests/portage/dep/test_dep_getusedep.py | 39 | ||||
-rw-r--r-- | tests/portage/dep/test_isvalidatom.py | 2 |
3 files changed, 52 insertions, 7 deletions
diff --git a/tests/portage/dep/test_dep_getslot.py b/tests/portage/dep/test_dep_getslot.py index 7c3004d05..d3b38917a 100644 --- a/tests/portage/dep/test_dep_getslot.py +++ b/tests/portage/dep/test_dep_getslot.py @@ -15,13 +15,17 @@ class DepGetSlot(TestCase): slot_char = ":" slots = ( "a", "1.2", "1", "IloveVapier", None ) cpvs = ["sys-apps/portage"] - + versions = ["2.1.1","2.1-r1"] for cpv in cpvs: - for slot in slots: - if slot: - self.assertEqual( dep_getslot( - cpv + slot_char + slot ), slot ) - else: - self.assertEqual( dep_getslot( cpv ), slot ) + for version in versions: + for slot in slots: + mycpv = cpv[:] + if version: + cpv += version + if slot: + self.assertEqual( dep_getslot( + cpv + slot_char + slot ), slot ) + else: + self.assertEqual( dep_getslot( cpv ), slot ) self.assertEqual( dep_getslot( "sys-apps/portage:"), "" ) diff --git a/tests/portage/dep/test_dep_getusedep.py b/tests/portage/dep/test_dep_getusedep.py new file mode 100644 index 000000000..c16632c94 --- /dev/null +++ b/tests/portage/dep/test_dep_getusedep.py @@ -0,0 +1,39 @@ +# test_dep_getusedeps.py -- Portage Unit Testing Functionality +# Copyright 2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: test_dep_getslot.py 5794 2007-01-27 18:16:08Z antarus $ + +from unittest import TestCase +from portage.dep import dep_getusedeps + +class DepGetUseDeps(TestCase): + """ A simple testcase for dep_getusedeps + """ + + def testDepGetUseDeps(self): + + useflags = [ '', 'foo', '-bar', ['baz','bar'], ['baz','-bar'] ] + cpvs = [ "sys-apps/portage" ] + slots = [ None, "0","1","linux-sources-2.5.7","randomstring" ] + versions = [ None, "2.1.1", "2.1.1-r2"] + for mycpv in cpvs: + for version in versions: + for slot in slots: + for use in useflags: + cpv = mycpv[:] + if version: + cpv += version + if slot: + cpv += ":" + slot + if isinstance( use, list ): + for u in use: + cpv = cpv + "[" + u + "]" + self.assertEqual( dep_getusedeps( + cpv ), use ) + else: + if len(use): + self.assertEqual( dep_getusedeps( + cpv + "[" + use + "]" ), [use] ) + else: + self.assertEqual( dep_getusedeps( + cpv + "[" + use + "]" ), [] ) diff --git a/tests/portage/dep/test_isvalidatom.py b/tests/portage/dep/test_isvalidatom.py index d373a52f0..88250e96c 100644 --- a/tests/portage/dep/test_isvalidatom.py +++ b/tests/portage/dep/test_isvalidatom.py @@ -20,6 +20,8 @@ class IsValidAtom(TestCase): ( ">sys-apps/portage-2.1", True ), ( "<sys-apps/portage-2.1", True ), ( "~sys-apps/portage-2.1", True ), + ( "sys-apps/portage-2.1:foo", True ), + ( "sys-apps/portage-2.1:", False ), ( ">~cate-gory/foo-1.0", False ), ( ">~category/foo-1.0", False ), ( "<~category/foo-1.0", False ), |