Tests: add sets/base/testInternalPackageSet
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 27 Jul 2010 09:32:22 +0000 (11:32 +0200)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 Jul 2010 19:01:23 +0000 (12:01 -0700)
pym/portage/tests/sets/base/__init__.py [new file with mode: 0644]
pym/portage/tests/sets/base/__test__ [new file with mode: 0644]
pym/portage/tests/sets/base/testInternalPackageSet.py [new file with mode: 0644]

diff --git a/pym/portage/tests/sets/base/__init__.py b/pym/portage/tests/sets/base/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pym/portage/tests/sets/base/__test__ b/pym/portage/tests/sets/base/__test__
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pym/portage/tests/sets/base/testInternalPackageSet.py b/pym/portage/tests/sets/base/testInternalPackageSet.py
new file mode 100644 (file)
index 0000000..70b3a14
--- /dev/null
@@ -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)