aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/repository.cc9
-rwxr-xr-xpython/repository_TEST.py14
2 files changed, 23 insertions, 0 deletions
diff --git a/python/repository.cc b/python/repository.cc
index f6f98e4..f479a84 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -209,6 +209,15 @@ void expose_repository()
"Fetch our versions."
)
+ .def("some_ids_might_support_action", &Repository::some_ids_might_support_action,
+ "some_ids_might_support_action(SupportsActionTestBase) -> bool\n"
+ "Might some of our IDs support a particular action?\n\n"
+
+ "Used to optimise PackageDatabase::query. If a repository doesn't\n"
+ "support, say, InstallAction, a query can skip searching it\n"
+ "entirely when looking for installable packages."
+ )
+
.add_property("use_interface", bp::make_function(&RepositoryWrapper::get_use_interface,
bp::return_internal_reference<>()),
"[ro] RepositoryUseInterface"
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index ed4d68c..0e3ca76 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -79,6 +79,20 @@ class TestCase_01_Repository(unittest.TestCase):
self.assertEquals(i, 0)
self.assertEquals(str(qpn), "foo/bar")
+ def test_11_some_ids_might_support_action(self):
+ self.assert_(repo.some_ids_might_support_action(SupportsFetchActionTest()))
+ self.assert_(not irepo.some_ids_might_support_action(SupportsFetchActionTest()))
+ self.assert_(repo.some_ids_might_support_action(SupportsInstallActionTest()))
+ self.assert_(not irepo.some_ids_might_support_action(SupportsInstallActionTest()))
+ self.assert_(not repo.some_ids_might_support_action(SupportsUninstallActionTest()))
+ self.assert_(irepo.some_ids_might_support_action(SupportsUninstallActionTest()))
+ self.assert_(not repo.some_ids_might_support_action(SupportsInstalledActionTest()))
+ self.assert_(irepo.some_ids_might_support_action(SupportsInstalledActionTest()))
+ self.assert_(repo.some_ids_might_support_action(SupportsPretendActionTest()))
+ self.assert_(not irepo.some_ids_might_support_action(SupportsPretendActionTest()))
+ self.assert_(not repo.some_ids_might_support_action(SupportsConfigActionTest()))
+ self.assert_(irepo.some_ids_might_support_action(SupportsConfigActionTest()))
+
class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def setUp(self):
global e, nce, db, repo, irepo