summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-06-10 19:08:46 -0700
committerZac Medico <zmedico@gentoo.org>2011-06-10 19:08:46 -0700
commitb7fbec5157cbe5a4faaa3d04d3656e354a805e11 (patch)
treed200765de689501cacf72dc0df1b16de4988e3a7
parent6d3bae4d1d48033668107863bf30d483792350e9 (diff)
downloadportage-b7fbec5157cbe5a4faaa3d04d3656e354a805e11.tar.gz
portage-b7fbec5157cbe5a4faaa3d04d3656e354a805e11.tar.bz2
portage-b7fbec5157cbe5a4faaa3d04d3656e354a805e11.zip
Add tests for fakedbapi.
-rw-r--r--pym/portage/tests/dbapi/__init__.py2
-rw-r--r--pym/portage/tests/dbapi/__test__0
-rw-r--r--pym/portage/tests/dbapi/test_fakedbapi.py42
3 files changed, 44 insertions, 0 deletions
diff --git a/pym/portage/tests/dbapi/__init__.py b/pym/portage/tests/dbapi/__init__.py
new file mode 100644
index 000000000..532918b6a
--- /dev/null
+++ b/pym/portage/tests/dbapi/__init__.py
@@ -0,0 +1,2 @@
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
diff --git a/pym/portage/tests/dbapi/__test__ b/pym/portage/tests/dbapi/__test__
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/pym/portage/tests/dbapi/__test__
diff --git a/pym/portage/tests/dbapi/test_fakedbapi.py b/pym/portage/tests/dbapi/test_fakedbapi.py
new file mode 100644
index 000000000..ed24782eb
--- /dev/null
+++ b/pym/portage/tests/dbapi/test_fakedbapi.py
@@ -0,0 +1,42 @@
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.dbapi.virtual import fakedbapi
+from portage.package.ebuild.config import config
+from portage.tests import TestCase
+
+class TestFakedbapi(TestCase):
+
+ def testFakedbapi(self):
+ packages = (
+ ("sys-apps/portage-2.1.10", {
+ "EAPI" : "2",
+ "IUSE" : "ipc doc",
+ "repository" : "gentoo",
+ "SLOT" : "0",
+ "USE" : "ipc",
+ }),
+ ("virtual/package-manager-0", {
+ "EAPI" : "0",
+ "repository" : "gentoo",
+ "SLOT" : "0",
+ }),
+ )
+
+ match_tests = (
+ ("sys-apps/portage:0[ipc]", ["sys-apps/portage-2.1.10"]),
+ ("sys-apps/portage:0[-ipc]", []),
+ ("sys-apps/portage:0[doc]", []),
+ ("sys-apps/portage:0[-doc]", ["sys-apps/portage-2.1.10"]),
+ ("sys-apps/portage:0::gentoo[ipc]", ["sys-apps/portage-2.1.10"]),
+ ("sys-apps/portage:0::multilib[ipc]", []),
+ ("virtual/package-manager", ["virtual/package-manager-0"]),
+ )
+
+ fakedb = fakedbapi(settings=config(config_profile_path=""))
+ for cpv, metadata in packages:
+ fakedb.cpv_inject(cpv, metadata=metadata)
+
+ for atom, expected_result in match_tests:
+ result = []
+ self.assertEqual( fakedb.match(atom), expected_result )