def testedifact0408(self): #differentenvelopingsamecontent: 1rst UNH per UNB, 2nd has 2 UNB for all UNH's, 3rd has UNG-UNE in1= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0408/040801.edi') in2= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0408/040802.edi') in3= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0408/040803.edi') for in1node,in2node,in3node in zip(in1.nextmessage(),in2.nextmessage(),in3.nextmessage()): self.failUnless(utilsunit.comparenode(in1node.root,in2node.root),'compare') self.failUnless(utilsunit.comparenode(in1node.root,in3node.root),'compare')
def testjsoninvoic02nocheck(self): ''' check 01.xml the same after rad&write/check ''' filein = 'botssys/infile/unitinmessagejson/org/invoic02.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/invoic01.xml' inn1 = inmessage.edifromfile(filename=filein,editype='jsonnocheck',messagetype='invoic') inn2 = inmessage.edifromfile(filename=filecomp,editype='xml',messagetype='invoic') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testjsoninvoic03(self): ''' test int, float in json ''' filein = 'botssys/infile/unitinmessagejson/org/invoic03.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/invoic02.xml' inn1 = inmessage.edifromfile(filename=filein,editype='json',messagetype='invoic') inn2 = inmessage.edifromfile(filename=filecomp,editype='xml',messagetype='invoic') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testinisoutjson03(self): ''' non-ascii-char''' filein = 'botssys/infile/unitinmessagejson/org/inisout04.json' fileout = 'botssys/infile/unitinmessagejson/output/inisout04.json' utilsunit.readwrite(editype='json',messagetype='jsonorder',filenamein=filein,filenameout=fileout) inn1 = inmessage.edifromfile(filename=filein,editype='jsonnocheck',messagetype='jsonnocheck') inn2 = inmessage.edifromfile(filename=fileout,editype='jsonnocheck',messagetype='jsonnocheck') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testinisoutjson01(self): filein = 'botssys/infile/unitinmessagejson/org/inisout01.json' fileout1 = 'botssys/infile/unitinmessagejson/output/inisout01.json' fileout3 = 'botssys/infile/unitinmessagejson/output/inisout03.json' utilsunit.readwrite(editype='json',messagetype='jsonorder',filenamein=filein,filenameout=fileout1) utilsunit.readwrite(editype='jsonnocheck',messagetype='jsonnocheck',filenamein=filein,filenameout=fileout3) inn1 = inmessage.edifromfile(filename=fileout1,editype='jsonnocheck',messagetype='jsonnocheck') inn2 = inmessage.edifromfile(filename=fileout3,editype='jsonnocheck',messagetype='jsonnocheck') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testjsoninvoic01nocheck(self): filein = 'botssys/infile/unitinmessagejson/org/invoic01.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/invoic01.xml' inn1 = inmessage.edifromfile(filename=filein, editype='jsonnocheck', messagetype='invoic') inn2 = inmessage.edifromfile(filename=filecomp, editype='xml', messagetype='invoic') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testjson11(self): filein = 'botssys/infile/unitinmessagejson/org/11.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/01.xml' inn1 = inmessage.edifromfile(filename=filein, editype='json', messagetype='articles') inn2 = inmessage.edifromfile(filename=filecomp, editype='xml', messagetype='articles') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testinisoutjson04(self): filein = 'botssys/infile/unitinmessagejson/org/inisout05.json' inn1 = inmessage.edifromfile(filename=filein, editype='jsonnocheck', messagetype='jsonnocheck', defaultBOTSIDroot='HEA') inn2 = inmessage.edifromfile(filename=filein, editype='json', messagetype='jsoninvoic') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testjsoninvoic02(self): ''' check 01.xml the same after rad&write/check ''' filein = 'botssys/infile/unitinmessagejson/org/invoic02.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/invoic01.xml' inn1 = inmessage.edifromfile(filename=filein, editype='json', messagetype='invoic') inn2 = inmessage.edifromfile(filename=filecomp, editype='xml', messagetype='invoic') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testedifact0403(self): #~ #test charsets self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040301.edi') #UNOA-regular OK for UNOA as UNOC self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040302F-generated.edi') #UNOA-regular OK for UNOA as UNOC in0= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040303.edi') #UNOA-regular also UNOA-strict in1= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040306.edi') #UNOA regular in2= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/T0000000005.edi') #UNOA regular in3= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/T0000000006.edi') #UNOA regular for in1node,in2node,in3node in zip(in1.nextmessage(),in2.nextmessage(),in3.nextmessage()): self.failUnless(utilsunit.comparenode(in1node.root,in2node.root),'compare') self.failUnless(utilsunit.comparenode(in1node.root,in3node.root),'compare') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040305.edi') #needs UNOA regular # in1= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040305.edi') #needs UNOA extended in7= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040304.edi') #UNOB-regular in5= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/T0000000008.edi') #UNOB regular in4= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/T0000000007-generated.edi') #UNOB regular in6= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/T0000000009.edi') #UNOC
def testjsoninvoic03(self): ''' test int, float in json ''' filein = 'botssys/infile/unitinmessagejson/org/invoic03.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/invoic02.xml' inn1 = inmessage.edifromfile(filename=filein, editype='json', messagetype='invoic') inn2 = inmessage.edifromfile(filename=filecomp, editype='xml', messagetype='invoic') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testedifact0408(self): #differentenvelopingsamecontent: 1rst UNH per UNB, 2nd has 2 UNB for all UNH's, 3rd has UNG-UNE in1 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0408/040801.edi') in2 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0408/040802.edi') in3 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0408/040803.edi') for in1node, in2node, in3node in zip(in1.nextmessage(), in2.nextmessage(), in3.nextmessage()): self.failUnless(utilsunit.comparenode(in1node.root, in2node.root), 'compare') self.failUnless(utilsunit.comparenode(in1node.root, in3node.root), 'compare')
def testinisoutjson03(self): ''' non-ascii-char''' filein = 'botssys/infile/unitinmessagejson/org/inisout04.json' fileout = 'botssys/infile/unitinmessagejson/output/inisout04.json' utilsunit.readwrite(editype='json', messagetype='jsonorder', filenamein=filein, filenameout=fileout) inn1 = inmessage.edifromfile(filename=filein, editype='jsonnocheck', messagetype='jsonnocheck') inn2 = inmessage.edifromfile(filename=fileout, editype='jsonnocheck', messagetype='jsonnocheck') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testinisoutjson01(self): filein = 'botssys/infile/unitinmessagejson/org/inisout01.json' fileout1 = 'botssys/infile/unitinmessagejson/output/inisout01.json' fileout3 = 'botssys/infile/unitinmessagejson/output/inisout03.json' utilsunit.readwrite(editype='json', messagetype='jsonorder', filenamein=filein, filenameout=fileout1) utilsunit.readwrite(editype='jsonnocheck', messagetype='jsonnocheck', filenamein=filein, filenameout=fileout3) inn1 = inmessage.edifromfile(filename=fileout1, editype='jsonnocheck', messagetype='jsonnocheck') inn2 = inmessage.edifromfile(filename=fileout3, editype='jsonnocheck', messagetype='jsonnocheck') self.failUnless(utilsunit.comparenode(inn1.root, inn2.root))
def testedifact0403(self): #~ #test charsets self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/040301.edi' ) #UNOA-regular OK for UNOA as UNOC self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename= 'botssys/infile/unitinmessageedifact/0403/040302F-generated.edi' ) #UNOA-regular OK for UNOA as UNOC in0 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/040303.edi' ) #UNOA-regular also UNOA-strict in1 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/040306.edi' ) #UNOA regular in2 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/T0000000005.edi' ) #UNOA regular in3 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/T0000000006.edi' ) #UNOA regular for in1node, in2node, in3node in zip(in1.nextmessage(), in2.nextmessage(), in3.nextmessage()): self.failUnless(utilsunit.comparenode(in1node.root, in2node.root), 'compare') self.failUnless(utilsunit.comparenode(in1node.root, in3node.root), 'compare') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/040305.edi' ) #needs UNOA regular #~ in1= inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0403/040305.edi') #needs UNOA extended in7 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/040304.edi' ) #UNOB-regular in5 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/T0000000008.edi' ) #UNOB regular in4 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename= 'botssys/infile/unitinmessageedifact/0403/T0000000007-generated.edi' ) #UNOB regular in6 = inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0403/T0000000009.edi' ) #UNOC
def testjsondiv(self): self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130101.json'), 'standaard test') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130101.json'), 'standaard test') #~ #empty object self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130102.json') #unknown field self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130103.json'), 'unknown field') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130103.json'), 'unknown field') self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130103.json' ) #unknown field #compare standard test with standard est with extra unknown fields and objects: must give same tree: in1 = inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130101.json') in2 = inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130115.json') self.failUnless(utilsunit.comparenode(in1.root, in2.root), 'compare') #numeriek field self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130105.json'), 'f****d up') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130105.json'), 'f****d up') self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130105.json' ) #f****d up self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130106.json'), 'f****d up') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130106.json'), 'f****d up') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130106.json' ) #f****d up self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130107.json'), 'f****d up') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130107.json'), 'f****d up') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130107.json' ) #f****d up #root is list with 3 messagetrees inn = inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130108.json') self.assertEqual(len(inn.root.children), 3, 'should deliver 3 messagetrees') inn = inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130108.json') self.assertEqual(len(inn.root.children), 3, 'should deliver 3 messagetrees') #root is list, but list has a non-object member self.failUnless( inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130109.json'), 'root is list, but list has a non-object member') self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130109.json'), 'root is list, but list has a non-object member') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130109.json' ) #root is list, but list has a non-object member self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130110.json' ) #too many occurences self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130111.json' ) #ent TEST1 should have a TEST2 self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130111.json'), 'ent TEST1 should have a TEST2') self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130111.json' ) #ent TEST1 should have a TEST2 self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130112.json' ) #ent TEST1 has a TEST2 self.failUnless( inmessage.edifromfile( editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130112.json'), 'ent TEST1 has a TEST2') self.assertRaises( botslib.MessageError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=True, filename='botssys/infile/unitinmessagejson/org/130112.json' ) #ent TEST1 has a TEST2 #unknown entries inn = inmessage.edifromfile( editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130113.json') #empty file self.assertRaises( ValueError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130114.json' ) #empty file self.assertRaises( ValueError, inmessage.edifromfile, editype='jsonnocheck', messagetype='jsonnocheck', filename='botssys/infile/unitinmessagejson/org/130114.json' ) #empty file #numeric key self.assertRaises( ValueError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130116.json') #key is list self.assertRaises( ValueError, inmessage.edifromfile, editype='json', messagetype='testjsonorder01', checkunknownentities=False, filename='botssys/infile/unitinmessagejson/org/130117.json')
def testjson11nocheck(self): filein = 'botssys/infile/unitinmessagejson/org/11.jsn' filecomp = 'botssys/infile/unitinmessagejson/comp/01.xml' inn1 = inmessage.edifromfile(filename=filein,editype='jsonnocheck',messagetype='articles') inn2 = inmessage.edifromfile(filename=filecomp,editype='xml',messagetype='articles') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testinisoutjson04(self): filein = 'botssys/infile/unitinmessagejson/org/inisout05.json' inn1 = inmessage.edifromfile(filename=filein,editype='jsonnocheck',messagetype='jsonnocheck',defaultBOTSIDroot='HEA') inn2 = inmessage.edifromfile(filename=filein,editype='json',messagetype='jsoninvoic') self.failUnless(utilsunit.comparenode(inn1.root,inn2.root))
def testjsondiv(self): self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130101.json'), 'standaard test') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130101.json'), 'standaard test') #empty object self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130102.json') #unknown field self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130103.json'), 'unknown field') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130103.json'), 'unknown field') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130103.json') #unknown field #compare standard test with standard est with extra unknown fields and objects: must give same tree: in1 = inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130101.json') in2 = inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130115.json') self.failUnless(utilsunit.comparenode(in1.root,in2.root),'compare') #numeriek field self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130104.json'), 'numeriek field') self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130105.json'), 'f****d up') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130105.json'), 'f****d up') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130105.json') #f****d up self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130106.json'), 'f****d up') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130106.json'), 'f****d up') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130106.json') #f****d up self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130107.json'), 'f****d up') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130107.json'), 'f****d up') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130107.json') #f****d up #root is list with 3 messagetrees inn = inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130108.json') self.assertEqual(len(inn.root.children), 3,'should deliver 3 messagetrees') inn = inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130108.json') self.assertEqual(len(inn.root.children), 3,'should deliver 3 messagetrees') #root is list, but list has a non-object member self.failUnless(inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130109.json'), 'root is list, but list has a non-object member') self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130109.json'), 'root is list, but list has a non-object member') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130109.json') #root is list, but list has a non-object member self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130110.json') #too many occurences self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130111.json') #ent TEST1 should have a TEST2 self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130111.json'), 'ent TEST1 should have a TEST2') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130111.json') #ent TEST1 should have a TEST2 self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130112.json') #ent TEST1 has a TEST2 self.failUnless(inmessage.edifromfile(editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130112.json'), 'ent TEST1 has a TEST2') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=True,filename='botssys/infile/unitinmessagejson/org/130112.json') #ent TEST1 has a TEST2 #unknown entries inn = inmessage.edifromfile(editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130113.json') #empty file self.assertRaises(ValueError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130114.json') #empty file self.assertRaises(ValueError,inmessage.edifromfile, editype='jsonnocheck',messagetype='jsonnocheck',filename='botssys/infile/unitinmessagejson/org/130114.json') #empty file #numeric key self.assertRaises(ValueError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130116.json') #key is list self.assertRaises(ValueError,inmessage.edifromfile, editype='json',messagetype='testjsonorder01',checkunknownentities=False,filename='botssys/infile/unitinmessagejson/org/130117.json')
def testxml(self): #~ #empty file self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110401.xml') self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xml',messagetype='testxml', filename='botssys/infile/unitinmessagexml/xml/110401.xml') self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True, filename='botssys/infile/unitinmessagexml/xml/110401.xml') self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xml',messagetype='testxmlflatten', filename='botssys/infile/unitinmessagexml/xml/110401.xml') #only root record in 110402.xml self.failUnless(inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110402.xml'), 'only a root tag; should be OK') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110402.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True, filename='botssys/infile/unitinmessagexml/xml/110402.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110402.xml') #root tag different from grammar self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110406.xml') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True, filename='botssys/infile/unitinmessagexml/xml/110406.xml') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110406.xml') #root tag is double self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110407.xml') #invalid: no closing tag self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110408.xml') #invalid: extra closing tag self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110409.xml') #invalid: mandatory xml-element missing self.failUnless(inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110410.xml'), '') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110410.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True, filename='botssys/infile/unitinmessagexml/xml/110410.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110410.xml') #invalid: to many occurences self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110411.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True, filename='botssys/infile/unitinmessagexml/xml/110411.xml') #invalid: missing mandatory xml attribute self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110412.xml') self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110412.xml') #unknown xml element self.assertRaises(botslib.MessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110413.xml') self.assertRaises(botslib.InMessageError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110414.xml') #2x the same xml attribute self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110415.xml') self.assertRaises(SyntaxError,inmessage.edifromfile, editype='xml',messagetype='testxml',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110415.xml') #messages with all max occurences, use attributes, etc in1 = inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110416.xml') #all elements, attributes #other order of xml elements; should esult in the same node tree in1 = inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110417.xml') #as 18., other order of elements in2 = inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110418.xml') self.failUnless(utilsunit.comparenode(in2.root,in1.root),'compare') #??what is tested here?? inn7= inmessage.edifromfile(editype='xml',messagetype='testxml',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110405.xml') #with <?xml version="1.0" encoding="utf-8"?> inn8= inmessage.edifromfile(editype='xml',messagetype='testxmlflatten',checkunknownentities=True,filename='botssys/infile/unitinmessagexml/xml/110405.xml') #with <?xml version="1.0" encoding="utf-8"?> self.failUnless(utilsunit.comparenode(inn7.root,inn8.root),'compare') #~ #test different file which should give equal results in1= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110403.xml') #no grammar used in5= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110404.xml') #no grammar used in6= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110405.xml') #no grammar used in2= inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110403.xml') #with <?xml version="1.0" encoding="utf-8"?> in3= inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110404.xml') #without <?xml version="1.0" encoding="utf-8"?> in4= inmessage.edifromfile(editype='xml',messagetype='testxml',filename='botssys/infile/unitinmessagexml/xml/110405.xml') #use cr/lf and whitespace for 'nice' xml self.failUnless(utilsunit.comparenode(in2.root,in1.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in3.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in4.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in5.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in6.root),'compare') #~ #test different file which should give equal results; flattenxml=True, in1= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110403.xml') #no grammar used in5= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110404.xml') #no grammar used in6= inmessage.edifromfile(editype='xmlnocheck',messagetype='xmlnocheck',filename='botssys/infile/unitinmessagexml/xml/110405.xml') #no grammar used in4= inmessage.edifromfile(editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110405.xml') #use cr/lf and whitespace for 'nice' xml in2= inmessage.edifromfile(editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110403.xml') #with <?xml version="1.0" encoding="utf-8"?> in3= inmessage.edifromfile(editype='xml',messagetype='testxmlflatten',filename='botssys/infile/unitinmessagexml/xml/110404.xml') #without <?xml version="1.0" encoding="utf-8"?> self.failUnless(utilsunit.comparenode(in2.root,in1.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in3.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in4.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in5.root),'compare') self.failUnless(utilsunit.comparenode(in2.root,in6.root),'compare')