summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-07-27 11:32:22 +0200
committerZac Medico <zmedico@gentoo.org>2010-07-27 12:01:23 -0700
commit279628b9d04e6c100d895c21d5812c65cf5a4423 (patch)
tree0a16056707b0506addd362abd3d353b16e145170
parentce5f914de66f8d6b658ad8585c482340b775a3db (diff)
downloadportage-279628b9d04e6c100d895c21d5812c65cf5a4423.tar.gz
portage-279628b9d04e6c100d895c21d5812c65cf5a4423.tar.bz2
portage-279628b9d04e6c100d895c21d5812c65cf5a4423.zip
Tests: add sets/base/testInternalPackageSet
-rw-r--r--pym/portage/tests/sets/base/__init__.py0
-rw-r--r--pym/portage/tests/sets/base/__test__0
-rw-r--r--pym/portage/tests/sets/base/testInternalPackageSet.py61
3 files changed, 61 insertions, 0 deletions
diff --git a/pym/portage/tests/sets/base/__init__.py b/pym/portage/tests/sets/base/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/pym/portage/tests/sets/base/__init__.py
diff --git a/pym/portage/tests/sets/base/__test__ b/pym/portage/tests/sets/base/__test__
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/pym/portage/tests/sets/base/__test__
diff --git a/pym/portage/tests/sets/base/testInternalPackageSet.py b/pym/portage/tests/sets/base/testInternalPackageSet.py
new file mode 100644
index 000000000..70b3a1401
--- /dev/null
+++ b/pym/portage/tests/sets/base/testInternalPackageSet.py
@@ -0,0 +1,61 @@
+# testConfigFileSet.py -- Portage Unit Testing Functionality
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.dep import Atom
+from portage.exception import InvalidAtom
+from portage.tests import TestCase
+from portage.sets.base import InternalPackageSet
+
+class InternalPackageSetTestCase(TestCase):
+ """Simple Test Case for InternalPackageSet"""
+
+ def testInternalPackageSet(self):
+ i1_atoms = set(("dev-libs/A", ">=dev-libs/A-1", "dev-libs/B"))
+ i2_atoms = set(("dev-libs/A", "dev-libs/*", "dev-libs/C"))
+
+ i1 = InternalPackageSet(initial_atoms=i1_atoms)
+ i2 = InternalPackageSet(initial_atoms=i2_atoms, allow_wildcard=True)
+ self.assertRaises(InvalidAtom, InternalPackageSet, initial_atoms=i2_atoms)
+
+ self.assertEqual(i1.getAtoms(), i1_atoms)
+ self.assertEqual(i2.getAtoms(), i2_atoms)
+
+ new_atom = Atom("*/*", allow_wildcard=True)
+ self.assertRaises(InvalidAtom, i1.add, new_atom)
+ i2.add(new_atom)
+
+ i2_atoms.add(new_atom)
+
+ self.assertEqual(i1.getAtoms(), i1_atoms)
+ self.assertEqual(i2.getAtoms(), i2_atoms)
+
+ removed_atom = Atom("dev-libs/A")
+
+ i1.remove(removed_atom)
+ i2.remove(removed_atom)
+
+ i1_atoms.remove(removed_atom)
+ i2_atoms.remove(removed_atom)
+
+ self.assertEqual(i1.getAtoms(), i1_atoms)
+ self.assertEqual(i2.getAtoms(), i2_atoms)
+
+ update_atoms = [Atom("dev-libs/C"), Atom("dev-*/C", allow_wildcard=True)]
+
+ self.assertRaises(InvalidAtom, i1.update, update_atoms)
+ i2.update(update_atoms)
+
+ i2_atoms.update(update_atoms)
+
+ self.assertEqual(i1.getAtoms(), i1_atoms)
+ self.assertEqual(i2.getAtoms(), i2_atoms)
+
+ replace_atoms = [Atom("dev-libs/D"), Atom("*-libs/C", allow_wildcard=True)]
+
+ self.assertRaises(InvalidAtom, i1.replace, replace_atoms)
+ i2.replace(replace_atoms)
+
+ i2_atoms = set(replace_atoms)
+
+ self.assertEqual(i2.getAtoms(), i2_atoms)