Skip to content

Commit 68e68bf

Browse files
author
Richard Jones
committed
unit test fixes
1 parent 9762fb3 commit 68e68bf

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

roundup/backends/back_anydbm.py

Lines changed: 3 additions & 3 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.146.2.22 2004-11-25 22:56:14 richard Exp $
18+
#$Id: back_anydbm.py,v 1.146.2.23 2004-11-25 23:46:21 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1650,14 +1650,14 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16501650
l.append((STRING, k, m))
16511651
elif isinstance(propclass, Date):
16521652
try:
1653-
date_rng = Range(v, date.Date, offset=timezone)
1653+
date_rng = date.Range(v, date.Date, offset=timezone)
16541654
l.append((DATE, k, date_rng))
16551655
except ValueError:
16561656
# If range creation fails - ignore that search parameter
16571657
pass
16581658
elif isinstance(propclass, Interval):
16591659
try:
1660-
intv_rng = Range(v, date.Interval)
1660+
intv_rng = date.Range(v, date.Interval)
16611661
l.append((INTERVAL, k, intv_rng))
16621662
except ValueError:
16631663
# If range creation fails - ignore that search parameter

roundup/backends/blobfiles.py

Lines changed: 4 additions & 3 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: blobfiles.py,v 1.12.2.5 2004-11-25 22:56:14 richard Exp $
18+
#$Id: blobfiles.py,v 1.12.2.6 2004-11-25 23:46:22 richard Exp $
1919
'''This module exports file storage for roundup backends.
2020
Files are stored into a directory hierarchy.
2121
'''
@@ -146,7 +146,8 @@ def rollbackStoreFile(self, classname, nodeid, property, **databases):
146146
'''
147147
# determine the name of the file to delete
148148
name = self.filename(classname, nodeid, property)
149-
if os.path.exists(name+".tmp"):
150-
os.remove(name+".tmp")
149+
if not name.endswith('.tmp'):
150+
name += '.tmp'
151+
os.remove(name)
151152

152153
# vim: set filetype=python ts=4 sw=4 et si

roundup/backends/rdbms_common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.98.2.27 2004-11-10 22:26:07 richard Exp $
1+
# $Id: rdbms_common.py,v 1.98.2.28 2004-11-25 23:46:22 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -2670,10 +2670,8 @@ def set(self, itemid, **propvalues):
26702670
if content:
26712671
# store and index
26722672
self.db.storefile(self.classname, itemid, None, content)
2673-
if self.getprops().has_key('type'):
2674-
mime_type = propvalues.get('type', self.get(itemid, 'type',
2675-
self.default_mime_type))
2676-
else:
2673+
mime_type = propvalues.get('type', self.get(itemid, 'type'))
2674+
if not mime_type:
26772675
mime_type = self.default_mime_type
26782676
self.db.indexer.add_text((self.classname, itemid, 'content'),
26792677
content, mime_type)

test/test_indexer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21-
# $Id: test_indexer.py,v 1.4 2004-03-19 04:47:59 richard Exp $
21+
# $Id: test_indexer.py,v 1.4.2.1 2004-11-25 23:46:22 richard Exp $
2222

2323
import os, unittest, shutil
2424

@@ -35,11 +35,10 @@ def setUp(self):
3535

3636
def test_basics(self):
3737
self.dex.add_text('testing1', 'a the hello world')
38-
self.assertEqual(self.dex.words, {'HELLO': {1: 1}, 'THE': {1: 1},
39-
'WORLD': {1: 1}})
38+
self.assertEqual(self.dex.words, {'HELLO': {1: 1}, 'WORLD': {1: 1}})
4039
self.dex.add_text('testing2', 'blah blah the world')
4140
self.assertEqual(self.dex.words, {'BLAH': {2: 2}, 'HELLO': {1: 1},
42-
'THE': {2: 1, 1: 1}, 'WORLD': {2: 1, 1: 1}})
41+
'WORLD': {2: 1, 1: 1}})
4342
self.assertEqual(self.dex.find(['world']), {2: 'testing2',
4443
1: 'testing1'})
4544
self.assertEqual(self.dex.find(['blah']), {2: 'testing2'})

0 commit comments

Comments
 (0)