def test_checkIsInMessage(self): self.object.setVersion(fix.BeginString_FIX40) self.object.addField(fix.BeginString().getTag()) self.object.addField(fix.BodyLength().getTag()) self.object.addField(fix.MsgType().getTag()) self.object.addField(fix.CheckSum().getTag()) self.object.addField(fix.TestReqID().getTag()) self.object.addField(fix.Symbol().getTag()) self.object.addMsgType(fix.MsgType_TestRequest) self.object.addMsgField(fix.MsgType_TestRequest, fix.TestReqID().getTag()) testReqID = fix.TestReqID("1") message = fix40.TestRequest() message.setField(testReqID) try: self.object.validate(message) self.failUnless(1) except fix.Exception as e: self.failUnless(0) message.setField(fix.Symbol("MSFT")) try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1)
def test_checkHasValue(self): message = fix40.TestRequest() message.setField(fix.TestReqID()) try: self.object.validate(message) self.failUnless(0) except fix.Exception, e: self.failUnless(1)
def test_checkHasValue(self): message = fix40.TestRequest() message.setField(fix.TestReqID()) try: self.object.validate(message) self.assertTrue(0) except fix.FIXException as e: self.assertTrue(1)
def test_checkHasRequired(self): self.object.setVersion(fix.BeginString_FIX40) self.object.addField(fix.BeginString().getTag()) self.object.addField(fix.BodyLength().getTag()) self.object.addField(fix.MsgType().getTag()) self.object.addField(fix.SenderCompID().getTag()) self.object.addField(fix.TargetCompID().getTag()) self.object.addHeaderField(fix.SenderCompID().getTag(), True) self.object.addHeaderField(fix.TargetCompID().getTag(), False) self.object.addField(fix.CheckSum().getTag()) self.object.addField(fix.TestReqID().getTag()) self.object.addMsgType(fix.MsgType_TestRequest) self.object.addMsgField(fix.MsgType_TestRequest, fix.TestReqID().getTag()) self.object.addRequiredField(fix.MsgType_TestRequest, fix.TestReqID().getTag()) message = fix40.TestRequest() try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1) message.getHeader().setField(fix.SenderCompID("SENDER")) try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1) message.setField(fix.TestReqID("1")) try: self.object.validate(message) self.failUnless(1) except fix.Exception as e: self.failUnless(0) message.getHeader().removeField(fix.SenderCompID().getTag()) message.setField(fix.SenderCompID("SENDER")) try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1)
def test_checkValidTagNumber(self): self.object.setVersion(fix.BeginString_FIX40) self.object.addField(fix.BeginString().getTag()) self.object.addField(fix.BodyLength().getTag()) self.object.addField(fix.MsgType().getTag()) self.object.addField(fix.CheckSum().getTag()) self.object.addField(fix.TestReqID().getTag()) self.object.addMsgType(fix.MsgType_TestRequest) self.object.addMsgField(fix.MsgType_TestRequest, fix.TestReqID().getTag()) testReqID = fix.TestReqID("1") message = fix40.TestRequest() message.setField(testReqID) message.setField(TooHigh("value")) try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1) self.object.addField(501) self.object.addMsgField(fix.MsgType_TestRequest, 501) try: self.object.validate(message) self.failUnless(1) except fix.Exception as e: self.failUnless(0) message.setField(5000, "value") try: self.object.validate(message) self.failUnless(0) except fix.Exception as e: self.failUnless(1) self.object.checkUserDefinedFields(False) try: self.object.validate(message) self.failUnless(1) except fix.Exception as e: self.failUnless(0)
def test_checkHasRequired(self): self.object.setVersion(fix.BeginString_FIX40) self.object.addField(fix.BeginString().getField()) self.object.addField(fix.BodyLength().getField()) 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.addField(fix.CheckSum().getField()) self.object.addField(fix.TestReqID().getField()) self.object.addMsgType(fix.MsgType_TestRequest) self.object.addMsgField(fix.MsgType_TestRequest, fix.TestReqID().getField()) self.object.addRequiredField(fix.MsgType_TestRequest, fix.TestReqID().getField()) message = fix40.TestRequest() try: self.object.validate(message) self.failUnless(0) except fix.Exception, e: self.failUnless(1)