def testcodeconversion(self): #codeconversion via tabel ccode OLD functionnames: self.assertEqual('TESTOUT',transform.codetconversion('artikel','TESTIN'),'basis') self.assertEqual('TESTOUT',transform.safecodetconversion('artikel','TESTIN'),'basis') self.assertEqual('TESTINNOT',transform.safecodetconversion('artikel','TESTINNOT'),'basis') self.assertRaises(botslib.CodeConversionError,transform.codetconversion,'artikel','TESTINNOT') self.assertEqual('TESTIN',transform.rcodetconversion('artikel','TESTOUT'),'basis') self.assertEqual('TESTIN',transform.safercodetconversion('artikel','TESTOUT'),'basis') self.assertEqual('TESTINNOT',transform.safercodetconversion('artikel','TESTINNOT'),'basis') self.assertRaises(botslib.CodeConversionError,transform.rcodetconversion,'artikel','TESTINNOT') #attributes self.assertEqual('TESTATTR1',transform.codetconversion('artikel','TESTIN','attr1'),'basis') self.assertEqual('TESTATTR1',transform.safecodetconversion('artikel','TESTIN','attr1'),'basis') #codeconversion via tabel ccode: self.assertEqual('TESTOUT',transform.ccode('artikel','TESTIN'),'basis') self.assertEqual('TESTOUT',transform.safe_ccode('artikel','TESTIN'),'basis') self.assertEqual('TESTINNOT',transform.safe_ccode('artikel','TESTINNOT'),'basis') self.assertRaises(botslib.CodeConversionError,transform.ccode,'artikel','TESTINNOT') self.assertEqual('TESTIN',transform.reverse_ccode('artikel','TESTOUT'),'basis') self.assertEqual('TESTIN',transform.safe_reverse_ccode('artikel','TESTOUT'),'basis') self.assertEqual('TESTINNOT',transform.safe_reverse_ccode('artikel','TESTINNOT'),'basis') self.assertRaises(botslib.CodeConversionError,transform.reverse_ccode,'artikel','TESTINNOT') #attributes self.assertEqual('TESTATTR1',transform.ccode('artikel','TESTIN','attr1'),'basis') self.assertEqual('TESTATTR1',transform.safe_ccode('artikel','TESTIN','attr1'),'basis')
def main(inn,out): for lin in inn.getloop({'BOTSID':'UNH'},{'BOTSID':'LOC'}): EANFILIAAL = lin.get({'BOTSID':'LOC','3227':'162','C517.3225':None}) EANFILIAAL=transform.safecodetconversion('adres',EANFILIAAL) SLSRPTDATUM = lin.get({'BOTSID':'LOC','3227':'162'},{'BOTSID':'DTM','C507.2005':'356','C507.2380':None}) for li2 in lin.getloop({'BOTSID':'LOC'},{'BOTSID':'LIN'}): lou = out.putloop({'BOTSID':'SLS'}) lou.put({'BOTSID':'SLS','EANFILIAAL':EANFILIAAL}) lou.put({'BOTSID':'SLS','SLSRPTDATUM':SLSRPTDATUM}) ARTIKEL = li2.get({'BOTSID':'LIN','C212.7140':None}) ARTIKEL=transform.safecodetconversion('artikel',ARTIKEL) lou.put({'BOTSID':'SLS','EANARTIKEL':ARTIKEL}) lou.put({'BOTSID':'SLS','AANTAL':li2.get({'BOTSID':'LIN'},{'BOTSID':'QTY', 'C186.6063':'153','C186.6060':None})}) lou.put({'BOTSID':'SLS','PRICE':li2.get({'BOTSID':'LIN'},{'BOTSID':'PRI', 'C509.5125':'NTP','C509.5118':None})})
def testcodeconversion(self): # codeconversion via tabel ccode OLD functionnames: self.assertEqual("TESTOUT", transform.codetconversion("artikel", "TESTIN"), "basis") self.assertEqual("TESTOUT", transform.safecodetconversion("artikel", "TESTIN"), "basis") self.assertEqual("TESTINNOT", transform.safecodetconversion("artikel", "TESTINNOT"), "basis") self.assertRaises( botslib.CodeConversionError, transform.codetconversion, "artikel", "TESTINNOT", ) self.assertEqual("TESTIN", transform.rcodetconversion("artikel", "TESTOUT"), "basis") self.assertEqual("TESTIN", transform.safercodetconversion("artikel", "TESTOUT"), "basis") self.assertEqual( "TESTINNOT", transform.safercodetconversion("artikel", "TESTINNOT"), "basis") self.assertRaises( botslib.CodeConversionError, transform.rcodetconversion, "artikel", "TESTINNOT", ) # attributes self.assertEqual( "TESTATTR1", transform.codetconversion("artikel", "TESTIN", "attr1"), "basis", ) self.assertEqual( "TESTATTR1", transform.safecodetconversion("artikel", "TESTIN", "attr1"), "basis", ) # codeconversion via tabel ccode: self.assertEqual("TESTOUT", transform.ccode("artikel", "TESTIN"), "basis") self.assertEqual("TESTOUT", transform.safe_ccode("artikel", "TESTIN"), "basis") self.assertEqual("TESTINNOT", transform.safe_ccode("artikel", "TESTINNOT"), "basis") self.assertRaises(botslib.CodeConversionError, transform.ccode, "artikel", "TESTINNOT") self.assertEqual("TESTIN", transform.reverse_ccode("artikel", "TESTOUT"), "basis") self.assertEqual("TESTIN", transform.safe_reverse_ccode("artikel", "TESTOUT"), "basis") self.assertEqual("TESTINNOT", transform.safe_reverse_ccode("artikel", "TESTINNOT"), "basis") self.assertRaises(botslib.CodeConversionError, transform.reverse_ccode, "artikel", "TESTINNOT") # attributes self.assertEqual("TESTATTR1", transform.ccode("artikel", "TESTIN", "attr1"), "basis") self.assertEqual("TESTATTR1", transform.safe_ccode("artikel", "TESTIN", "attr1"), "basis")