summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/virtual.py
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-09-07 10:14:12 +0000
committerAlec Warner <antarus@gentoo.org>2007-09-07 10:14:12 +0000
commitf77868a5f27b87d053e000667992ecb4cb78d335 (patch)
tree6856d4ffbb6cc157378f302ba13cf16a9ea312cc /pym/portage/dbapi/virtual.py
parenta4acda03bac43cc972dfaf9fda4d5210860d3d93 (diff)
downloadportage-f77868a5f27b87d053e000667992ecb4cb78d335.tar.gz
portage-f77868a5f27b87d053e000667992ecb4cb78d335.tar.bz2
portage-f77868a5f27b87d053e000667992ecb4cb78d335.zip
dbapi currently depends on being subclassed and having the subclasses impelement certain functions (that aren't even implemented IN dbapi, so a particular child has no idea what functions are actually required). Try to make this cleared by adding stubs in dbapi. There should be no behavior change here because these cases would be Attribute errors in the current scheme. Also add a horribly bad testdbapi with stub funcs to use in testing code. Remove regexes with possibly faster string comparisons.
svn path=/main/trunk/; revision=7752
Diffstat (limited to 'pym/portage/dbapi/virtual.py')
-rw-r--r--pym/portage/dbapi/virtual.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/pym/portage/dbapi/virtual.py b/pym/portage/dbapi/virtual.py
index 467eb032c..30f51ceaf 100644
--- a/pym/portage/dbapi/virtual.py
+++ b/pym/portage/dbapi/virtual.py
@@ -4,11 +4,12 @@
from portage.dbapi import dbapi
-
from portage import cpv_getkey
class fakedbapi(dbapi):
- "This is a dbapi to use for the emptytree function. It's empty, but things can be added to it."
+ """A fake dbapi that allows consumers to inject/remove packages to/from it
+ portage.settings is required to maintain the dbAPI.
+ """
def __init__(self, settings=None):
self.cpvdict = {}
self.cpdict = {}
@@ -90,3 +91,19 @@ class fakedbapi(dbapi):
def aux_update(self, cpv, values):
self._clear_cache()
self.cpvdict[cpv].update(values)
+
+class testdbapi(object):
+ """A dbapi instance with completely fake functions to get by hitting disk
+ TODO(antarus):
+ This class really needs to be rewritten to have better stubs; but these work for now.
+ The dbapi classes themselves need unit tests...and that will be a lot of work.
+ """
+
+ def __init__(self):
+ self.cpvs = {}
+ def f(*args, **kwargs):
+ return True
+ fake_api = dir(dbapi)
+ for call in fake_api:
+ if not hasattr(self, call):
+ setattr(self, call, f) \ No newline at end of file