~sidnei/storm/mssql-support

« back to all changes in this revision

Viewing changes to tests/database.py

  • Committer: Gustavo Niemeyer
  • Date: 2007-08-07 23:15:09 UTC
  • mfrom: (156.1.8 preset-primary-key)
  • Revision ID: gustavo@niemeyer.net-20070807231509-iw58uiygzuef5wth
Merged preset-primary-key branch [r=radix,jkakar] [f=126080]

This branch introduces a new hook which allows backends to modify
variables which are part of the primary key of an object before
they are inserted in the database.  Also, lazy values may now be
used in the primary key, which means that it's possible to set these
primary variables to SQL expressions if needed.

Other minor changes include an optimization in Result: it will
preset the raw cursor's arraysize to a better value if it's found
to be 1.  Result.__iter__() was also fixed to parse rows through
the from_database hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
216
216
                          [("fetchall0",), ("fetchall1",)])
217
217
        self.assertEquals(self.result.get_all(), [])
218
218
 
219
 
    def test_iter_arraysize_1(self):
220
 
        self.assertEquals([item for item in self.result],
221
 
                          [("fetchone0",), ("fetchone1",), ("fetchone2",),])
222
 
 
223
 
    def test_iter_arraysize_2(self):
 
219
    def test_iter(self):
224
220
        result = Result(None, RawCursor(2))
225
221
        self.assertEquals([item for item in result],
226
222
                          [("fetchmany0",), ("fetchmany1",), ("fetchmany2",),
256
252
        self.result._raw_cursor = None
257
253
        self.result.__del__()
258
254
 
 
255
    def test_set_arraysize(self):
 
256
        """When the arraysize is 1, change it to a better value."""
 
257
        raw_cursor = RawCursor()
 
258
        self.assertEquals(raw_cursor.arraysize, 1)
 
259
        result = Result(None, raw_cursor)
 
260
        self.assertEquals(raw_cursor.arraysize, 10)
 
261
 
 
262
    def test_preserve_arraysize(self):
 
263
        """When the arraysize is not 1, preserve it."""
 
264
        raw_cursor = RawCursor(arraysize=123)
 
265
        result = Result(None, raw_cursor)
 
266
        self.assertEquals(raw_cursor.arraysize, 123)
 
267
 
259
268
 
260
269
class CreateDatabaseTest(TestHelper):
261
270