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 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 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 testedifact0407(self): #lex test with characters in strange places self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040701.edi') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040702.edi'), 'standaard test') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040703.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040704.edi') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040705.edi'), 'standaard test') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040706.edi'), 'UNOA Crtl-Z at end') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040707.edi'), 'UNOB Crtl-Z at end') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0407/040708.edi'), 'UNOC Crtl-Z at end')
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 testinisoutjson02(self): #fails. this is because list of messages is read; and these are written in one time....nice for next release... filein = 'botssys/infile/unitinmessagejson/org/inisout05.json' fileout = 'botssys/infile/unitinmessagejson/output/inisout05.json' inn = inmessage.edifromfile(editype='json',messagetype='jsoninvoic',filename=filein) out = outmessage.outmessage_init(editype='json',messagetype='jsoninvoic',filename=fileout,divtext='',topartner='') #make outmessage object #~ inn.root.display() out.root = inn.root out.writeall() inn1 = inmessage.edifromfile(filename=filein,editype='jsonnocheck',messagetype='jsonnocheck',defaultBOTSIDroot='HEA') inn2 = inmessage.edifromfile(filename=fileout,editype='jsonnocheck',messagetype='jsonnocheck')
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 testedifact0407(self): #lex test with characters in strange places self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040701.edi') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040702.edi' ), 'standaard test') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040703.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040704.edi') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040705.edi' ), 'standaard test') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040706.edi' ), 'UNOA Crtl-Z at end') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040707.edi' ), 'UNOB Crtl-Z at end') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0407/040708.edi' ), 'UNOC Crtl-Z at end')
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 testidoc01(self): filenamein='botssys/infile/unitinisout/org/inisout01.idoc' filenameout='botssys/infile/unitinisout/output/inisout01.idoc' inn = inmessage.edifromfile(editype='idoc',messagetype='WP_PLU02',filename=filenamein) out = outmessage.outmessage_init(editype='idoc',messagetype='WP_PLU02',filename=filenameout,divtext='',topartner='') #make outmessage object out.root = inn.root out.writeall() self.failUnless(filecmp.cmp('bots/' + filenameout,'bots/' + filenamein))
def testedifact02(self): infile ='botssys/infile/unitinisout/org/inisout02.edi' outfile='botssys/infile/unitinisout/output/inisout02.edi' inn = inmessage.edifromfile(editype='edifact',messagetype='orderswithenvelope',filename=infile) out = outmessage.outmessage_init(editype='edifact',messagetype='orderswithenvelope',filename=outfile,divtext='',topartner='') #make outmessage object out.root = inn.root out.writeall() self.failUnless(filecmp.cmp('bots/' + outfile,'bots/' + infile))
def testedifact03(self): #~ #display query correct? incluuding propagating 'down the tree'? node.Node.fetchqueries = fetchqueries inn = inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitnode/0T0000000015.edi') inn.root.processqueries({},2) inn.root.fetchqueries() #~ print collectqueries comparequeries = {u'UNH': {'reference': u'UNBREF', 'messagetype': u'ORDERSD96AUNEAN008', 'reference2': u'UNBREF', 'topartner': u'PARTNER2', 'alt': u'50EAB', 'alt2': u'50E9', 'frompartner': u'PARTNER1'}, u'UNB': {'topartner': u'PARTNER2', 'reference2': u'UNBREF', 'reference': u'UNBREF', 'frompartner': u'PARTNER1'}, u'UNZ': {'reference': u'UNBREF', 'reference2': u'UNBREF', 'topartner': u'PARTNER2', 'frompartner': u'PARTNER1'}} self.assertEqual(comparequeries,collectqueries)
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 testx12_02(self): filenamein='botssys/infile/unitinisout/org/inisout02.x12' filenameout='botssys/infile/unitinisout/output/inisout02.x12' inn = inmessage.edifromfile(editype='x12',messagetype='850withenvelope',filename=filenamein) out = outmessage.outmessage_init(add_crlfafterrecord_sep='',editype='x12',messagetype='850withenvelope',filename=filenameout,divtext='',topartner='') #make outmessage object out.root = inn.root out.writeall() linesfile1 = utilsunit.readfile('bots/' + filenamein) linesfile2 = utilsunit.readfile('bots/' + filenameout) self.assertEqual(linesfile1[:103],linesfile2[:103],'first part of ISA') self.assertEqual(linesfile1[105:],linesfile2[103:],'rest of message')
def testedifact0404(self): #envelope tests self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040401.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040402.edi') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040403.edi'), 'standaard test') self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040404.edi') self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040405.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040406.edi') #self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040407.edi') #syntax version '0'; is not checked anymore self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040408.edi') self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040409.edi') self.failUnless(inmessage.edifromfile(editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040410.edi'), 'standaard test') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040411.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040412.edi') self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040413.edi') self.assertRaises(botslib.MessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040414.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040415.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040416.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040417.edi') self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040418.edi')
def testx12_01(self): filenamein='botssys/infile/unitinisout/org/inisout01.x12' filenameout='botssys/infile/unitinisout/output/inisout01.x12' inn = inmessage.edifromfile(editype='x12',messagetype='850withenvelope',filename=filenamein) out = outmessage.outmessage_init(editype='x12',messagetype='850withenvelope',filename=filenameout,divtext='',topartner='') #make outmessage object out.root = inn.root out.writeall() linesfile1 = utilsunit.readfilelines('bots/' + filenamein) linesfile2 = utilsunit.readfilelines('bots/' + filenameout) self.assertEqual(linesfile1[0][:103],linesfile2[0][:103],'first part of ISA') for line1,line2 in zip(linesfile1[1:],linesfile2[1:]): self.assertEqual(line1,line2,'Cmplines')
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 testinisoutjson02(self): #fails. this is because list of messages is read; and these are written in one time....nice for next release... filein = 'botssys/infile/unitinmessagejson/org/inisout05.json' fileout = 'botssys/infile/unitinmessagejson/output/inisout05.json' inn = inmessage.edifromfile(editype='json', messagetype='jsoninvoic', filename=filein) out = outmessage.outmessage_init(editype='json', messagetype='jsoninvoic', filename=fileout, divtext='', topartner='') #make outmessage object # inn.root.display() out.root = inn.root out.writeall() inn1 = inmessage.edifromfile(filename=filein, editype='jsonnocheck', messagetype='jsonnocheck', defaultBOTSIDroot='HEA') inn2 = inmessage.edifromfile(filename=fileout, editype='jsonnocheck', messagetype='jsonnocheck')
def testedifact02(self): infile = 'botssys/infile/unitinisout/org/inisout02.edi' outfile = 'botssys/infile/unitinisout/output/inisout02.edi' inn = inmessage.edifromfile(editype='edifact', messagetype='orderswithenvelope', filename=infile) out = outmessage.outmessage_init(editype='edifact', messagetype='orderswithenvelope', filename=outfile, divtext='', topartner='') #make outmessage object out.root = inn.root out.writeall() self.failUnless(filecmp.cmp('bots/' + outfile, 'bots/' + infile))
def testidoc01(self): filenamein = 'botssys/infile/unitinisout/org/inisout01.idoc' filenameout = 'botssys/infile/unitinisout/output/inisout01.idoc' inn = inmessage.edifromfile(editype='idoc', messagetype='WP_PLU02', filename=filenamein) out = outmessage.outmessage_init(editype='idoc', messagetype='WP_PLU02', filename=filenameout, divtext='', topartner='') #make outmessage object out.root = inn.root out.writeall() self.failUnless( filecmp.cmp('bots/' + filenameout, 'bots/' + filenamein))
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 testx12_01(self): filenamein = 'botssys/infile/unitinisout/org/inisout01.x12' filenameout = 'botssys/infile/unitinisout/output/inisout01.x12' inn = inmessage.edifromfile(editype='x12', messagetype='850withenvelope', filename=filenamein) out = outmessage.outmessage_init(editype='x12', messagetype='850withenvelope', filename=filenameout, divtext='', topartner='') #make outmessage object out.root = inn.root out.writeall() linesfile1 = utilsunit.readfilelines('bots/' + filenamein) linesfile2 = utilsunit.readfilelines('bots/' + filenameout) self.assertEqual(linesfile1[0][:103], linesfile2[0][:103], 'first part of ISA') for line1, line2 in zip(linesfile1[1:], linesfile2[1:]): self.assertEqual(line1, line2, 'Cmplines')
def testx12_02(self): filenamein = 'botssys/infile/unitinisout/org/inisout02.x12' filenameout = 'botssys/infile/unitinisout/output/inisout02.x12' inn = inmessage.edifromfile(editype='x12', messagetype='850withenvelope', filename=filenamein) out = outmessage.outmessage_init(add_crlfafterrecord_sep='', editype='x12', messagetype='850withenvelope', filename=filenameout, divtext='', topartner='') #make outmessage object out.root = inn.root out.writeall() linesfile1 = utilsunit.readfile('bots/' + filenamein) linesfile2 = utilsunit.readfile('bots/' + filenameout) self.assertEqual(linesfile1[:103], linesfile2[:103], 'first part of ISA') self.assertEqual(linesfile1[105:], linesfile2[103:], 'rest of message')
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 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 testedifact0404(self): #envelope tests self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040401.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040402.edi') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040403.edi' ), 'standaard test') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040404.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040405.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040406.edi') #self.assertRaises(botslib.InMessageError,inmessage.edifromfile,editype='edifact',messagetype='edifact',filename='botssys/infile/unitinmessageedifact/0404/040407.edi') #syntax version '0'; is not checked anymore self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040408.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040409.edi') self.failUnless( inmessage.edifromfile( editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040410.edi' ), 'standaard test') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040411.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040412.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040413.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040414.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040415.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040416.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040417.edi') self.assertRaises( botslib.InMessageError, inmessage.edifromfile, editype='edifact', messagetype='edifact', filename='botssys/infile/unitinmessageedifact/0404/040418.edi')
def testedifact01(self): inn = inmessage.edifromfile(editype='edifact',messagetype='invoicwithenvelope',filename='botssys/infile/unitnode/nodetest01.edi') out = outmessage.outmessage_init(editype='edifact',messagetype='invoicwithenvelope',filename='botssys/infile/unitnode/output/inisout03.edi',divtext='',topartner='') #make outmessage object out.root = inn.root #* getloop ************************************** count = 0 for t in inn.getloop({'BOTSID':'XXX'}): count += 1 self.assertEqual(count,0,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'}): count += 1 self.assertEqual(count,2,'Cmplines') count = 0 for t in out.getloop({'BOTSID':'UNB'},{'BOTSID':'XXX'}): count += 1 self.assertEqual(count,0,'Cmplines') count = 0 for t in out.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'}): count += 1 self.assertEqual(count,3,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'XXX'}): count += 1 self.assertEqual(count,0,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'}): count += 1 self.assertEqual(count,6,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'},{'BOTSID':'XXX'},{'BOTSID':'LIN'},{'BOTSID':'QTY'}): count += 1 self.assertEqual(count,0,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'XXX'}): count += 1 self.assertEqual(count,0,'Cmplines') count = 0 for t in inn.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'QTY'}): count += 1 self.assertEqual(count,6,'Cmplines') #* getcount, getcountmpath ************************************** count = 0 countlist=[5,0,1] nrsegmentslist=[132,10,12] for t in out.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'}): count2 = 0 for u in t.getloop({'BOTSID':'UNH'},{'BOTSID':'LIN'}): count2 += 1 count3 = t.getcountoccurrences({'BOTSID':'UNH'},{'BOTSID':'LIN'}) self.assertEqual(t.getcount(),nrsegmentslist[count],'Cmplines') self.assertEqual(count2,countlist[count],'Cmplines') self.assertEqual(count3,countlist[count],'Cmplines') count += 1 self.assertEqual(out.getcountoccurrences({'BOTSID':'UNB'},{'BOTSID':'UNH'}),count,'Cmplines') self.assertEqual(out.getcount(),sum(nrsegmentslist,4),'Cmplines') #* get, getnozero, countmpath, sort************************************** for t in out.getloop({'BOTSID':'UNB'},{'BOTSID':'UNH'}): self.assertRaises(botslib.MappingRootError,out.get,()) self.assertRaises(botslib.MappingRootError,out.getnozero,()) self.assertRaises(botslib.MappingRootError,out.get,0) self.assertRaises(botslib.MappingRootError,out.getnozero,0) t.sort({'BOTSID':'UNH'},{'BOTSID':'LIN','C212.7140':None}) start='0' for u in t.getloop({'BOTSID':'UNH'},{'BOTSID':'LIN'}): nextstart = u.get({'BOTSID':'LIN','C212.7140':None}) self.failUnless(start<nextstart) start = nextstart t.sort({'BOTSID':'UNH'},{'BOTSID':'LIN','1082':None}) start='0' for u in t.getloop({'BOTSID':'UNH'},{'BOTSID':'LIN'}): nextstart = u.get({'BOTSID':'LIN','1082':None}) self.failUnless(start<nextstart) start = nextstart self.assertRaises(botslib.MappingRootError,out.get,()) self.assertRaises(botslib.MappingRootError,out.getnozero,()) #~ # self.assertRaises(botslib.MpathError,out.get,()) first=True for t in out.getloop({'BOTSID':'UNB'}): if first: self.assertEqual('15',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN','1082':None}),'Cmplines') self.assertEqual('8',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'QTY','C186.6063':'47','C186.6060':None}),'Cmplines') self.assertEqual('0',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'QTY','C186.6063':'12','C186.6060':None}),'Cmplines') self.assertEqual('54.4',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'MOA','C516.5025':'203','C516.5004':None}),'Cmplines') first = False else: self.assertEqual('1',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'QTY','C186.6063':'47','C186.6060':None}),'Cmplines') self.assertEqual('0',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'QTY','C186.6063':'12','C186.6060':None}),'Cmplines') self.assertEqual('0',t.getcountsum({'BOTSID':'UNB'},{'BOTSID':'UNH'},{'BOTSID':'LIN'},{'BOTSID':'MOA','C516.5025':'203','C516.5004':None}),'Cmplines')
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 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')
def readwrite(filenamein='',filenameout='',**args): inn = inmessage.edifromfile(filename=filenamein,**args) out = outmessage.outmessage_init(filename=filenameout,divtext='',topartner='',**args) #make outmessage object out.root = inn.root out.writeall()
def testedifact02(self): #~ #display query correct? incluuding propagating 'down the tree'? inn = inmessage.edifromfile(editype='edifact',messagetype='invoicwithenvelopetestquery',filename='botssys/infile/unitnode/nodetest01.edi') inn.root.processqueries({},2) inn.root.displayqueries()
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