Skip to content

Commit ec75bcb

Browse files
author
Richard Jones
committed
more unit tests to improve coverage (up from 85% to 88% for anydbm! :)
1 parent 24c878b commit ec75bcb

File tree

3 files changed

+161
-77
lines changed

3 files changed

+161
-77
lines changed

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.132 2003-11-16 18:41:40 jlgijsbers Exp $
18+
#$Id: back_anydbm.py,v 1.133 2003-12-05 09:47:46 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -310,13 +310,6 @@ def getnode(self, classname, nodeid, db=None, cache=1):
310310
if db is None:
311311
db = self.getclassdb(classname)
312312
if not db.has_key(nodeid):
313-
# try the cache - might be a brand-new node
314-
cache_dict = self.cache.setdefault(classname, {})
315-
if cache_dict.has_key(nodeid):
316-
if __debug__:
317-
print >>hyperdb.TRACE, 'get %s %s cached'%(classname,
318-
nodeid)
319-
return cache_dict[nodeid]
320313
raise IndexError, "no such %s %s"%(classname, nodeid)
321314

322315
# check the uncommitted, destroyed nodes
@@ -1540,7 +1533,7 @@ def stringFind(self, **requirements):
15401533
'''
15411534
for propname in requirements.keys():
15421535
prop = self.properties[propname]
1543-
if isinstance(not prop, String):
1536+
if not isinstance(prop, String):
15441537
raise TypeError, "'%s' not a String property"%propname
15451538
requirements[propname] = requirements[propname].lower()
15461539
l = []

roundup/backends/rdbms_common.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.71 2003-11-16 18:41:40 jlgijsbers Exp $
1+
# $Id: rdbms_common.py,v 1.72 2003-12-05 09:47:46 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -155,19 +155,7 @@ def post_init(self):
155155
self.conn.commit()
156156

157157
def refresh_database(self):
158-
# now detect changes in the schema
159-
for classname, spec in self.classes.items():
160-
dbspec = self.database_schema[classname]
161-
self.update_class(spec, dbspec, force=1)
162-
self.database_schema[classname] = spec.schema()
163-
# update the database version of the schema
164-
self.sql('delete from schema')
165-
self.save_dbschema(self.database_schema)
166-
# reindex the db
167-
self.reindex()
168-
# commit
169-
self.conn.commit()
170-
158+
self.post_init()
171159

172160
def reindex(self):
173161
for klass in self.classes.values():
@@ -1800,8 +1788,8 @@ def find(self, **propspec):
18001788
raise TypeError, "'%s' not a Link/Multilink property"%propname
18011789

18021790
# first, links
1803-
where = []
1804-
allvalues = ()
1791+
where = ['__retired__ = %s']
1792+
allvalues = (0,)
18051793
a = self.db.arg
18061794
for prop, values in propspec:
18071795
if not isinstance(props[prop], hyperdb.Link):
@@ -1852,14 +1840,16 @@ def stringFind(self, **requirements):
18521840
args = []
18531841
for propname in requirements.keys():
18541842
prop = self.properties[propname]
1855-
if isinstance(not prop, String):
1843+
if not isinstance(prop, String):
18561844
raise TypeError, "'%s' not a String property"%propname
18571845
where.append(propname)
18581846
args.append(requirements[propname].lower())
18591847

18601848
# generate the where clause
18611849
s = ' and '.join(['lower(_%s)=%s'%(col, self.db.arg) for col in where])
1862-
sql = 'select id from _%s where %s'%(self.classname, s)
1850+
sql = 'select id from _%s where %s and __retired__=%s'%(self.classname,
1851+
s, self.db.arg)
1852+
args.append(0)
18631853
self.db.sql(sql, tuple(args))
18641854
l = [x[0] for x in self.db.sql_fetchall()]
18651855
if __debug__:

0 commit comments

Comments
 (0)