diff options
Diffstat (limited to 'pym/portage/tests/dep')
-rw-r--r-- | pym/portage/tests/dep/__init__.py | 4 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_dep_getcpv.py | 41 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_dep_getslot.py | 31 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_dep_getusedeps.py | 39 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_get_operator.py | 31 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_isjustname.py | 25 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_isvalidatom.py | 38 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_match_from_list.py | 31 |
8 files changed, 240 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/__init__.py b/pym/portage/tests/dep/__init__.py new file mode 100644 index 000000000..a3226c133 --- /dev/null +++ b/pym/portage/tests/dep/__init__.py @@ -0,0 +1,4 @@ +# tests/portage.dep/__init__.py -- Portage Unit Test functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ diff --git a/pym/portage/tests/dep/test_dep_getcpv.py b/pym/portage/tests/dep/test_dep_getcpv.py new file mode 100644 index 000000000..11fd1a723 --- /dev/null +++ b/pym/portage/tests/dep/test_dep_getcpv.py @@ -0,0 +1,41 @@ +# test_dep_getcpv.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import dep_getcpv + +class DepGetCPV(TestCase): + """ A simple testcase for isvalidatom + """ + + def testDepGetCPV(self): + + prefix_ops = ["<", ">", "=", "~", "!", "<=", + ">=", "!=", "!<", "!>", "!~",""] + + bad_prefix_ops = [ ">~", "<~", "~>", "~<" ] + postfix_ops = [ "*", "" ] + + cpvs = ["sys-apps/portage", "sys-apps/portage-2.1", "sys-apps/portage-2.1", + "sys-apps/portage-2.1"] + slots = [None,":",":2"] + for cpv in cpvs: + for slot in slots: + for prefix in prefix_ops: + for postfix in postfix_ops: + if slot: + self.assertEqual( dep_getcpv( + prefix + cpv + slot + postfix ), cpv ) + else: + self.assertEqual( dep_getcpv( + prefix + cpv + postfix ), cpv ) + for prefix in bad_prefix_ops: + for postfix in postfix_ops: + if slot: + self.assertNotEqual( dep_getcpv( + prefix + cpv + slot + postfix ), cpv ) + else: + self.assertNotEqual( dep_getcpv( + prefix + cpv + postfix ), cpv )
\ No newline at end of file diff --git a/pym/portage/tests/dep/test_dep_getslot.py b/pym/portage/tests/dep/test_dep_getslot.py new file mode 100644 index 000000000..d3b38917a --- /dev/null +++ b/pym/portage/tests/dep/test_dep_getslot.py @@ -0,0 +1,31 @@ +# test_dep_getslot.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import dep_getslot + +class DepGetSlot(TestCase): + """ A simple testcase for isvalidatom + """ + + def testDepGetSlot(self): + + 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 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/pym/portage/tests/dep/test_dep_getusedeps.py b/pym/portage/tests/dep/test_dep_getusedeps.py new file mode 100644 index 000000000..d191d43cc --- /dev/null +++ b/pym/portage/tests/dep/test_dep_getusedeps.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 + +import sys +from portage.tests import test_cpvs, test_slots, test_versions, test_usedeps + +class DepGetUseDeps(TestCase): + """ A simple testcase for dep_getusedeps + """ + + def testDepGetUseDeps(self): + + + for mycpv in test_cpvs: + for version in test_versions: + for slot in test_slots: + for use in test_usedeps: + 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/pym/portage/tests/dep/test_get_operator.py b/pym/portage/tests/dep/test_get_operator.py new file mode 100644 index 000000000..b41fab0d5 --- /dev/null +++ b/pym/portage/tests/dep/test_get_operator.py @@ -0,0 +1,31 @@ +# test_match_from_list.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import get_operator + +class GetOperator(TestCase): + + def testGetOperator(self): + + # get_operator does not validate operators + tests = [ ( "~", "~" ), ( "=", "=" ), ( ">", ">" ), + ( ">=", ">=" ), ( "<=", "<=" ) , ( "", None ), + ( ">~", ">" ), ("~<", "~"), ( "=~", "=" ), + ( "=>", "=" ), ("=<", "=") ] + + test_cpvs = ["sys-apps/portage","sys-apps/portage-2.1"] + slots = [ None,"1","linux-2.5.6" ] + for cpv in test_cpvs: + for test in tests: + for slot in slots: + atom = cpv[:] + if slot: + atom += ":" + slot + result = get_operator( test[0] + atom ) + self.assertEqual( result, test[1] ) + + result = get_operator( "=sys-apps/portage*" ) + self.assertEqual( result , "=*" ) diff --git a/pym/portage/tests/dep/test_isjustname.py b/pym/portage/tests/dep/test_isjustname.py new file mode 100644 index 000000000..e419e3f26 --- /dev/null +++ b/pym/portage/tests/dep/test_isjustname.py @@ -0,0 +1,25 @@ +# test_isjustname.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import isjustname + +class IsJustName(TestCase): + + def testIsJustName(self): + + cats = ( "", "sys-apps/", "foo/", "virtual/" ) + pkgs = ( "portage", "paludis", "pkgcore", "notARealPkg" ) + vers = ( "", "-2.0-r3", "-1.0_pre2", "-3.1b" ) + + for pkg in pkgs: + for cat in cats: + for ver in vers: + if len(ver): + self.assertFalse( isjustname( cat + pkg + ver ), + msg="isjustname(%s) is True!" % (cat + pkg + ver) ) + else: + self.assertTrue( isjustname( cat + pkg + ver ), + msg="isjustname(%s) is False!" % (cat + pkg + ver) ) diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py new file mode 100644 index 000000000..88250e96c --- /dev/null +++ b/pym/portage/tests/dep/test_isvalidatom.py @@ -0,0 +1,38 @@ +# test_isvalidatom.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import isvalidatom + +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-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 ), + ( "###cat/foo-1.0", False ), + ( "~sys-apps/portage", False ), + ( "portage", False ) ] + + for test in tests: + if test[1]: + atom_type = "valid" + else: + atom_type = "invalid" + self.assertEqual( bool(isvalidatom( test[0] )), test[1], + msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) ) diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py new file mode 100644 index 000000000..4868184a6 --- /dev/null +++ b/pym/portage/tests/dep/test_match_from_list.py @@ -0,0 +1,31 @@ +# test_match_from_list.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from unittest import TestCase +from portage.dep import match_from_list + +class AtomCmpEqualGlob(TestCase): + """ A simple testcase for =* glob matching + """ + + def testEqualGlobPass(self): + tests = [ ("=sys-apps/portage-45*", "sys-apps/portage-045" ), + ("=sys-fs/udev-1*", "sys-fs/udev-123"), + ("=sys-fs/udev-4*", "sys-fs/udev-456" ) ] + +# I need to look up the cvs syntax +# ("=sys-fs/udev_cvs*","sys-fs/udev_cvs_pre4" ) ] + + for test in tests: + self.assertEqual( len(match_from_list( test[0], [test[1]] )), 1 ) + + def testEqualGlobFail(self): + tests = [ ("=sys-apps/portage-2*", "sys-apps/portage-2.1" ), + ("=sys-apps/portage-2.1*", "sys-apps/portage-2.1.2" ) ] + for test in tests: + try: + self.assertEqual( len( match_from_list( test[0], [test[1]] ) ), 1 ) + except TypeError: # failure is ok here + pass |