Commit 7d3fc177 authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Add tests for setNull/isNull in Records.

Add tests for browseObjects with payload queries for nullness.
Split the FieldSelection tests for reference and nullness 
(the latter work ok in ROOT6 even without any wrapping).


git-svn-id: file:///git/lcgcool.svndb/cool/tags/COOL_3_0_2@19268 4525493e-7705-40b1-a816-d608a930855b
parent fb717cb9
......@@ -23,6 +23,15 @@ class TestIFolder( unittest.TestCase ):
return payload
def dummyPayloadNull( self ):
"""Creates a dummy payload Record with null fields"""
payload = cool.Record( self.rspec )
payload.field("I").setNull() # EQUIVALENT TO: payload["I"] = None
payload["S"] = "NULL" # Avoid ""/NULL issues for this simple test!...
payload.field("X").setNull() # EQUIVALENT TO: payload["X"] = None
return payload
def setUp(self):
try:
if self.rspec is None:
......@@ -338,7 +347,7 @@ class TestIFolder( unittest.TestCase ):
# test payload queries (move to different test?)
def test_fieldSelection(self):
def test_fieldSelection_reference(self):
if "COOL_PYCOOLTEST_SKIP_EXCEPTIONS" in os.environ: return # ROOT6
# instantiate FieldSelections for all supported types
fs = cool.FieldSelection("i",
......@@ -405,6 +414,9 @@ class TestIFolder( unittest.TestCase ):
cool.StorageType.Blob16M,
cool.FieldSelection.EQ,
cool.Blob16M(10))
# test payload queries (move to different test?)
def test_fieldSelection_nullness(self):
# instantiate FieldSelections for all supported types
# using check for nullness constructor
fs = cool.FieldSelection("i",
......@@ -479,8 +491,8 @@ class TestIFolder( unittest.TestCase ):
cs.connect( cool.CompositeSelection.AND, fs3 )
# test browseObjects with RecordSelection
def test_browseObjectsRecordSelection(self):
# test browseObjects with RecordSelection for reference values
def test_browseObjectsRecordSelection_reference(self):
f = self.db.createFolder( '/a', self.fspecSV )
f.setupStorageBuffer()
f.storeObject( 0, 2, self.dummyPayload( 0 ), 0 )
......@@ -509,6 +521,39 @@ class TestIFolder( unittest.TestCase ):
self.assertEquals( objs.currentRef().until(), 4 )
# test browseObjects with RecordSelection for nullness
def test_browseObjectsRecordSelection_nullness(self):
f = self.db.createFolder( '/a', self.fspecSV )
f.setupStorageBuffer()
nulPld = self.dummyPayloadNull()
self.assert_( nulPld.field("I").isNull() )
self.assert_( nulPld.field("X").isNull() )
self.assert_( nulPld["I"] == None )
self.assert_( nulPld["S"] == "NULL" )
self.assert_( nulPld["X"] == None )
dumPld = self.dummyPayload( 0 )
self.assert_( not dumPld.field("I").isNull() )
self.assert_( not dumPld.field("X").isNull() )
self.assert_( dumPld["I"] != None )
self.assert_( dumPld["X"] != None )
f.storeObject( 0, 2, dumPld, 0 )
f.storeObject( 2, 4, nulPld, 0 )
f.flushStorageBuffer()
fs = cool.FieldSelection("I",
cool.StorageType.Int32,
cool.FieldSelection.IS_NULL)
objs = f.browseObjects( cool.ValidityKeyMin,
cool.ValidityKeyMax,
cool.ChannelSelection(0),
"",
fs )
self.assertEquals( 1, objs.size() )
objs.goToNext()
self.assertEquals( objs.currentRef().payload(), self.dummyPayloadNull() )
self.assertEquals( objs.currentRef().since(), 2 )
self.assertEquals( objs.currentRef().until(), 4 )
#######################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment