add some new tests
authorAlec Warner <antarus@gentoo.org>
Thu, 1 Feb 2007 05:22:21 +0000 (05:22 -0000)
committerAlec Warner <antarus@gentoo.org>
Thu, 1 Feb 2007 05:22:21 +0000 (05:22 -0000)
svn path=/main/trunk/; revision=5853

tests/portage/dep/test_dep_getslot.py
tests/portage/dep/test_dep_getusedep.py [new file with mode: 0644]
tests/portage/dep/test_isvalidatom.py

index 7c3004d050831fc0f67c2daf299d1742082a1ec5..d3b38917a66ce11ea9ee4488b30d67467f684efd 100644 (file)
@@ -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 (file)
index 0000000..c16632c
--- /dev/null
@@ -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 + "]" ), [] )
index d373a52f050e52324e8be3b130a98662a5fcf56e..88250e96cda601e41ab08f5e54736b90cb8d32f0 100644 (file)
@@ -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 ),