Skip to content

Commit

Permalink
Updated python test cases for api changes. Booleans are now real bool…
Browse files Browse the repository at this point in the history
…eans, not integers
  • Loading branch information
orenmnero committed Sep 15, 2014
1 parent 19d0140 commit 7b09c99
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/python/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
export LD_LIBRARY_PATH=../../src/C++/.libs
export DYLD_LIBRARY_PATH=../../src/C++/.libs
export PYTHONPATH=../../lib/python

python test/DataDictionaryTestCase.py
Expand Down
14 changes: 7 additions & 7 deletions src/python/test/DataDictionaryTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def test_addMsgField(self):
def test_addHeaderField(self):
self.failUnless( self.object.isHeaderField( 56 ) == 0 )
self.failUnless( self.object.isHeaderField( 49 ) == 0 )
self.object.addHeaderField( 56, 1 )
self.object.addHeaderField( 49, 1 )
self.object.addHeaderField( 56, True )
self.object.addHeaderField( 49, True )
self.failUnless( self.object.isHeaderField( 56 ) )
self.failUnless( self.object.isHeaderField( 49 ) )

def test_addTrailerField(self):
self.failUnless( self.object.isTrailerField( 10 ) == 0 )
self.object.addTrailerField( 10, 1 )
self.object.addTrailerField( 10, True )
self.failUnless( self.object.isTrailerField( 10 ) )

def test_addRequiredField(self):
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_checkValidTagNumber(self):
except fix.Exception, e:
self.failUnless( 1 )

self.object.checkUserDefinedFields( 0 )
self.object.checkUserDefinedFields( False )
try:
self.object.validate( message )
self.failUnless( 1 )
Expand Down Expand Up @@ -213,8 +213,8 @@ def test_checkHasRequired(self):
self.object.addField( fix.MsgType().getField() )
self.object.addField( fix.SenderCompID().getField() )
self.object.addField( fix.TargetCompID().getField() )
self.object.addHeaderField( fix.SenderCompID().getField(), 1 )
self.object.addHeaderField( fix.TargetCompID().getField(), 0 )
self.object.addHeaderField( fix.SenderCompID().getField(), True )
self.object.addHeaderField( fix.TargetCompID().getField(), False )
self.object.addField( fix.CheckSum().getField() )
self.object.addField( fix.TestReqID().getField() )
self.object.addMsgType( fix.MsgType_TestRequest )
Expand Down Expand Up @@ -251,4 +251,4 @@ def test_checkHasRequired(self):
self.failUnless( 1 )

if __name__ == '__main__':
unittest.main()
unittest.main()
18 changes: 9 additions & 9 deletions src/python/test/DictionaryTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ def test_setGetString(self):

self.assertEquals( "STRINGVALUE1", self.object.getString("STRINGKEY1") )
self.assertEquals( "stringvalue2", self.object.getString("STRINGKEY2") )
self.assertEquals( "STRINGVALUE2", self.object.getString("STRINGKEY2", 1) )
self.assertEquals( "STRINGVALUE2", self.object.getString("STRINGKEY2", True) )

try:
self.object.getString( "STRINGKEY3" )
self.failUnless( 0 )
except fix.ConfigError, e:
self.failUnless( 1 )

def test_setGetLong(self):
self.object.setLong( "LONGKEY1", 12 )
self.object.setLong( "LONGKEY2", 9827362 )
def test_setGetInt(self):
self.object.setInt( "LONGKEY1", 12 )
self.object.setInt( "LONGKEY2", 9827362 )
self.object.setString( "BADLONGKEY", "AB12" )

self.assertEquals( 12, self.object.getLong("LONGKEY1") )
self.assertEquals( 9827362, self.object.getLong("LONGKEY2") )
self.assertEquals( 12, self.object.getInt("LONGKEY1") )
self.assertEquals( 9827362, self.object.getInt("LONGKEY2") )

try:
self.object.getLong( "LONGKEY3" )
self.object.getInt( "LONGKEY3" )
self.failUnless( 0 )
except fix.ConfigError, e:
self.failUnless( 1 )

try:
self.object.getLong( "BADLONGKEY" )
self.object.getInt( "BADLONGKEY" )
self.failUnless( 0 )
except fix.ConfigError, e:
self.failUnless( 1 )
Expand Down Expand Up @@ -105,4 +105,4 @@ def test_merge(self):
self.failUnless( self.object.getString( "THIRDKEY" ) == "FIRST" );

if __name__ == '__main__':
unittest.main()
unittest.main()
14 changes: 7 additions & 7 deletions src/python/test/MessageTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_setString(self):
try:
self.object.setString( strGood )
self.object.setString( strNull )
self.object.setString( strNoLengthAndChk, 0 )
self.object.setString( strNoLengthAndChk, False )
except fix.InvalidMessage, e:
self.failUnless( 0 )

Expand Down Expand Up @@ -106,15 +106,15 @@ def test_setString(self):
self.failUnless(1)

dataDictionary = fix.DataDictionary()
dataDictionary.addHeaderField( 11, 0 )
dataDictionary.addTrailerField( 60, 0 )
dataDictionary.addHeaderField( 11, False )
dataDictionary.addTrailerField( 60, False )

clOrdID = fix.ClOrdID()
transactTime = fix.TransactTime()
symbol = fix.Symbol()

try:
self.object.setString( strBodyFields, 1, dataDictionary )
self.object.setString( strBodyFields, True, dataDictionary )
except fix.InvalidMessage, e:
self.failUnless( 0 )

Expand All @@ -127,7 +127,7 @@ def test_setStringWithGroup(self):
str = "8=FIX.4.3\0019=199\00135=E\00134=126\00149=BUYSIDE\00150=00303\00152=20040916-16:19:18.328\00156=SELLSIDE\00166=1095350459\00168=2\00173=2\00111=1095350459\00167=1\0011=00303\00155=fred\00154=1\00140=1\00159=3\00111=1095350460\00167=2\0011=00303\00155=fred\00154=1\00140=1\00159=3\001394=3\00110=138\001"

try:
self.object.setString( str, 1, dataDictionary )
self.object.setString( str, True, dataDictionary )
self.assertEquals( str, self.object.toString() )
except fix.InvalidMessage, e:
assert( 0 )
Expand All @@ -137,7 +137,7 @@ def test_setStringWithHeaderGroup(self):
str = "8=FIX.4.3\0019=152\00135=A\00134=125\00149=BUYSIDE\00152=20040916-16:19:18.328\00156=SELLSIDE\001627=2\001628=HOP1\001629=20040916-16:19:18.328\001630=ID1\001628=HOP2\001629=20040916-16:19:18.328\001630=ID2\00110=079\001"

try:
self.object.setString( str, 1, dataDictionary )
self.object.setString( str, True, dataDictionary )
self.assertEquals( str, self.object.toString() )
except fix.InvalidMessage, e:
assert( 0 )
Expand All @@ -148,7 +148,7 @@ def test_outOfOrder(self):
expected = "8=FIX.4.2\0019=171\00135=8\00134=2\00149=MEK\00156=KEM\0011=acct1\0016=109.03125\00111=ID1\00114=3000\00115=USD\00117=2\00120=0\00122=1\00131=109.03125\00137=1\00138=3000\00139=2\00148=123ABC789\00154=1\00155=ABCD\00160=00000000-00:00:00\001150=2\001151=0\00110=225\001"

try:
self.object.setString( str, 0 )
self.object.setString( str, False )
self.assertEquals( expected, self.object.toString() )
except fix.InvalidMessage, e:
self.failUnless(0)
Expand Down

0 comments on commit 7b09c99

Please sign in to comment.