Esempio n. 1
0
 def testunique(self):
     newdomain = 'test' + transform.unique('test')
     self.assertEqual('1',transform.unique(newdomain),'init new domain')
     self.assertEqual('2',transform.unique(newdomain),'next one')
     
     newdomain = 'test' + transform.unique('test')
     self.assertEqual(True,transform.checkunique(newdomain,1),'init new domain')
     self.assertEqual(False,transform.checkunique(newdomain,1),'seq should be 2')
     self.assertEqual(False,transform.checkunique(newdomain,3),'seq should be 2')
     self.assertEqual(True,transform.checkunique(newdomain,2),'next one')
def main(channeldict, *args, **kargs):
    output_dir = botslib.join(channeldict['path'])
    botslib.dirshouldbethere(output_dir)
    url = 'http://{}:{}/api/shipping_invoice/'.format(
        channeldict['host'], channeldict['port'])
    custom_headers = {
        'Authorization': 'Token {}'.format(channeldict['parameters']),
        'Content-Type': 'application/json'
    }
    invoices = requests.get(url, headers=custom_headers)

    for invoice in invoices.json():
        filename = botslib.join(output_dir, str(
            transform.unique('Shipping Invoice Get')) + '.json')
        output_file = open(filename, 'wb')
        output_file.write(json.dumps({'Invoice': invoice}))
        output_file.close()

        # Mark invoice as processed
        url = 'http://{}:{}/api/shipping_invoice/{}/processed/'.format(
            channeldict['host'], channeldict['port'], invoice['invoice_id'])
        process_invoice = requests.post(url, headers=custom_headers)
        process_invoice.raise_for_status()

        # Return the filename
        yield filename
Esempio n. 3
0
 def testunique(self):
     newdomain = 'test' + transform.unique('test')
     self.assertEqual(True, transform.checkunique(newdomain, 1),
                      'init new domain')
     self.assertEqual(False, transform.checkunique(newdomain, 1),
                      'seq should be 2')
     self.assertEqual(False, transform.checkunique(newdomain, 3),
                      'seq should be 2')
     self.assertEqual(True, transform.checkunique(newdomain, 2), 'next one')
def main(inn,out):
    out.ta_info['topartner'] = inn.ta_info['frompartner']
    out.ta_info['frompartner'] = inn.ta_info['topartner']
    out.ta_info['testindicator'] = inn.ta_info['testindicator']
    ref = transform.unique('messagecounter')
    out.put({'BOTSID':'UNH','0062':ref,'S009.0065':'APERAK','S009.0052':'D','S009.0054':'96A','S009.0051':'UN'})
    out.put({'BOTSID':'UNH'},{'BOTSID':'BGM','1004':ref})
    out.put({'BOTSID':'UNH'},{'BOTSID':'DTM','C507.2005':'137','C507.2379':'203','C507.2380':time.strftime('%Y%m%d%H%M')})
    srtmes = inn.get({'BOTSID':'UNH'},{'BOTSID':'BGM','C002.1001':None})
    srtmes = transform.ccode('aperakrff2qualifer',srtmes)
    out.put({'BOTSID':'UNH'},{'BOTSID':'RFF','C506.1153':srtmes,'C506.1154':inn.get({'BOTSID':'UNH'},{'BOTSID':'BGM','1004':None})})
    mesdate = inn.get({'BOTSID':'UNH'},{'BOTSID':'DTM','C507.2005':'137','C507.2380':None})
    mesformat = inn.get({'BOTSID':'UNH'},{'BOTSID':'DTM','C507.2005':'137','C507.2379':None})
    out.put({'BOTSID':'UNH'},{'BOTSID':'RFF','C506.1153':srtmes},{'BOTSID':'DTM','C507.2005':'171','C507.2379':mesformat,'C507.2380':mesdate})
        

    for nad in inn.getloop({'BOTSID':'UNH'},{'BOTSID':'NAD'}):
        nad2 = out.putloop({'BOTSID':'UNH'},{'BOTSID':'NAD'})
        nad2.put({'BOTSID':'NAD','3035':nad.get({'BOTSID':'NAD','3035':None})})
        nad2.put({'BOTSID':'NAD','C082.3039':nad.get({'BOTSID':'NAD','C082.3039':None})})
        nad2.put({'BOTSID':'NAD','C082.3055':nad.get({'BOTSID':'NAD','C082.3055':None})})
    out.put({'BOTSID':'UNH'},{'BOTSID':'UNT','0074':out.getcount()+1,'0062':ref})
Esempio n. 5
0
 def testunique(self):
     newdomain = 'test' + transform.unique('test')
     self.assertEqual('1', transform.unique(newdomain), 'init new domain')
     self.assertEqual('2', transform.unique(newdomain), 'next one')
Esempio n. 6
0
 def testunique(self):
     newdomain = 'test' + transform.unique('test')
     self.assertEqual('1',transform.unique(newdomain),'init new domain')
     self.assertEqual('2',transform.unique(newdomain),'next one')
def main(inn, out):
    out.put(
        {'BOTSID': 'STX'}
    )  #for tradacoms: dummy root node is created (is not used!! for eg envelope)

    sender = inn.ta_info['frompartner']
    out.ta_info['frompartner'] = sender

    receiver = inn.ta_info['topartner']
    out.ta_info['topartner'] = receiver

    if 'testindicator' not in inn.ta_info:
        inn.ta_info['testindicator'] = '0'
        out.ta_info['testindicator'] = '0'

    messagecounter = 0
    ordercounter = 0
    isfirstmessage = True
    for mes in inn.getloop({'BOTSID': 'envelope'}, {'BOTSID': 'message'}):
        if isfirstmessage:
            #~ #do the ORDHDR
            isfirstmessage = False
            messagecounter += 1
            ord = out.putloop({'BOTSID': 'STX'}, {'BOTSID': 'MHD'})
            ord.put({
                'BOTSID': 'MHD',
                'TYPE.01': 'ORDHDR',
                'TYPE.02': '9',
                'MSRF': messagecounter
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID': 'TYP',
                'TCDE': mes.get({
                    'BOTSID': 'message',
                    'docsrt': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID': 'TYP',
                'TTYP': mes.get({
                    'BOTSID': 'message',
                    'mesfunc': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SIDN.01':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'gln': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SIDN.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'bilnum': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SNAM':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'name': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SADD.01':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'addressline1': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SADD.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'addressline2': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SADD.03':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'addressline3': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SADD.04':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'addressline4': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'SADD.05':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'pcode': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'SDT',
                'VATN.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'SU',
                    'vatnum': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CIDN.01':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'gln': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CIDN.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'bilnum': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CNAM':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'name': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CADD.01':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'addressline1': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CADD.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'addressline2': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CADD.03':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'addressline3': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CADD.04':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'addressline4': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'CADD.05':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'pcode': None
                })
            })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'CDT',
                'VATR.02':
                mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                    'BOTSID': 'party',
                    'qual': 'BY',
                    'vatnum': None
                })
            })
            ord.put(
                {'BOTSID': 'MHD'}, {
                    'BOTSID': 'FIL',
                    'FLVN': '1',
                    'FLDT': transform.strftime('%y%m%d'),
                    'FLGN':
                    transform.unique('ORDHDR' + inn.ta_info['topartner'])
                })
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID': 'MTR',
                'NOSG': ord.getcount() + 1
            })

        #~ #do the ORDERS
        messagecounter += 1
        ordercounter += 1
        ord = out.putloop({'BOTSID': 'STX'}, {'BOTSID': 'MHD'})
        ord.put({
            'BOTSID': 'MHD',
            'TYPE.01': 'ORDERS',
            'TYPE.02': '9',
            'MSRF': messagecounter
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CLOC.01':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'gln': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CLOC.02':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'bilnum': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CLOC.03':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'intcustomernum': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CNAM':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'name': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CADD.01':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'addressline1': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CADD.02':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'addressline2': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CADD.03':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'addressline3': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CADD.04':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'addressline4': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'CLO',
            'CADD.05':
            mes.get({'BOTSID': 'message'}, {'BOTSID': 'partys'}, {
                'BOTSID': 'party',
                'qual': 'DP',
                'pcode': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'ORNO.01': mes.get({
                'BOTSID': 'message',
                'docnum': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'ORNO.02': mes.get({
                'BOTSID': 'message',
                'docnumvv': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'ORD',
            'ORNO.03':
            datewithoutcc(mes.get({
                'BOTSID': 'message',
                'docdtm': None
            }))
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'ORD',
            'ORNO.04':
            datewithoutcc(mes.get({
                'BOTSID': 'message',
                'docdtmvv': None
            }))
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'CLAS': mes.get({
                'BOTSID': 'message',
                'classification': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'ORCD': mes.get({
                'BOTSID': 'message',
                'orcd': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'SCRF.01': mes.get({
                'BOTSID': 'message',
                'projectnum': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'ORD',
            'SCRF.02': mes.get({
                'BOTSID': 'message',
                'contractnum': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'DIN',
            'EDAT':
            datewithoutcc(mes.get({
                'BOTSID': 'message',
                'earldeldtm': None
            }))
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID':
            'DIN',
            'LDAT':
            datewithoutcc(mes.get({
                'BOTSID': 'message',
                'latedeldtm': None
            }))
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'DIN',
            'RATM.01': mes.get({
                'BOTSID': 'message',
                'deltimefrom': None
            })
        })
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'DIN',
            'RATM.02': mes.get({
                'BOTSID': 'message',
                'deltimetill': None
            })
        })

        count = 0
        for deltxt in mes.getloop({'BOTSID': 'message'}, {'BOTSID': 'txts'}, {
                'BOTSID': 'txt',
                'qual': 'DEL'
        }):
            count += 1
            ord.put({'BOTSID': 'MHD'}, {
                'BOTSID':
                'DIN',
                'DINS.0' + str(count):
                deltxt.get({
                    'BOTSID': 'txt',
                    'val': None
                })
            })
        linecounter = 0
        for lin in mes.getloop({'BOTSID': 'message'}, {'BOTSID': 'lines'},
                               {'BOTSID': 'line'}):
            linecounter += 1
            xlin = ord.putloop({'BOTSID': 'MHD'}, {'BOTSID': 'OLD'})
            xlin.put({'BOTSID': 'OLD', 'SEQA': linecounter})
            xlin.put({
                'BOTSID': 'OLD',
                'SPRO.01': lin.get({
                    'BOTSID': 'line',
                    'gtin': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'SPRO.02': lin.get({
                    'BOTSID': 'line',
                    'suart': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'CPRO.02': lin.get({
                    'BOTSID': 'line',
                    'byart': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'SACU': lin.get({
                    'BOTSID': 'line',
                    'gtincu': None
                })
            })
            xlin.put({
                'BOTSID':
                'OLD',
                'UNOR.01':
                lin.get({
                    'BOTSID': 'line',
                    'numbergtincu': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'UNOR.02': lin.get({
                    'BOTSID': 'line',
                    'ordqua': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'UNOR.03': lin.get({
                    'BOTSID': 'line',
                    'ordunit': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'OQTY.03': lin.get({
                    'BOTSID': 'line',
                    'ordunit': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'OQTY.01': lin.get({
                    'BOTSID': 'line',
                    'num': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'TDES.01': lin.get({
                    'BOTSID': 'line',
                    'desc': None
                })
            })
            xlin.put({
                'BOTSID': 'OLD',
                'SPIND': lin.get({
                    'BOTSID': 'line',
                    'pdnum': None
                })
            })
            xlin.put({
                'BOTSID':
                'OLD',
                'SCRF.02':
                lin.get({
                    'BOTSID': 'line',
                    'contractnum': None
                })
            })
        ord.put({'BOTSID': 'MHD'}, {'BOTSID': 'OTR', 'LORD': linecounter})
        ord.put({'BOTSID': 'MHD'}, {
            'BOTSID': 'MTR',
            'NOSG': ord.getcount() + 1
        })

    #~ #do the ORDTLR
    messagecounter += 1
    ord = out.putloop({'BOTSID': 'STX'}, {'BOTSID': 'MHD'})
    ord.put({
        'BOTSID': 'MHD',
        'TYPE.01': 'ORDTLR',
        'TYPE.02': '9',
        'MSRF': messagecounter
    })
    ord.put({'BOTSID': 'MHD'}, {'BOTSID': 'OFT', 'FTOR': ordercounter})
    ord.put({'BOTSID': 'MHD'}, {'BOTSID': 'MTR', 'NOSG': ord.getcount() + 1})
Esempio n. 8
0
    def testunique(self):
        newdomain = 'test' + transform.unique('test')
        self.assertEqual('1',transform.unique(newdomain),'init new domain')
        self.assertEqual('2',transform.unique(newdomain),'next one')
        self.assertEqual('3',transform.unique(newdomain),'next one')
        self.assertEqual('4',transform.unique(newdomain),'next one')
        
        newdomain = 'test' + transform.unique('test')
        self.assertEqual(True,transform.checkunique(newdomain,1),'init new domain')
        self.assertEqual(False,transform.checkunique(newdomain,1),'seq should be 2')
        self.assertEqual(False,transform.checkunique(newdomain,3),'seq should be 2')
        self.assertEqual(True,transform.checkunique(newdomain,2),'next one')
        self.assertEqual(True,transform.checkunique(newdomain,3),'next one')
        self.assertEqual(True,transform.checkunique(newdomain,4),'next one')
        self.assertEqual(False,transform.checkunique(newdomain,4),'next one')
        self.assertEqual(False,transform.checkunique(newdomain,6),'next one')
        self.assertEqual(True,transform.checkunique(newdomain,5),'next one')

        newdomain = 'test' + transform.unique('test')
        self.assertEqual('1',transform.unique(newdomain),'init new domain')
        self.assertEqual('1',transform.unique(newdomain,updatewith=999),'init new domain')
        self.assertEqual('999',transform.unique(newdomain,updatewith=9999),'init new domain')
        self.assertEqual('9999',transform.unique(newdomain,updatewith=9999),'init new domain')
        self.assertEqual('9999',transform.unique(newdomain,updatewith=20140404),'init new domain')
        self.assertEqual('20140404',transform.unique(newdomain,updatewith=20140405),'init new domain')
        self.assertEqual('20140405',transform.unique(newdomain,updatewith=20140406),'init new domain')
        self.assertEqual('20140406',transform.unique(newdomain,updatewith=20140407),'init new domain')
        self.assertEqual('20140407',transform.unique(newdomain,updatewith=20140408),'init new domain')
Esempio n. 9
0
    def testunique(self):
        newdomain = 'test' + transform.unique('test')
        self.assertEqual('1', transform.unique(newdomain), 'init new domain')
        self.assertEqual('2', transform.unique(newdomain), 'next one')
        self.assertEqual('3', transform.unique(newdomain), 'next one')
        self.assertEqual('4', transform.unique(newdomain), 'next one')

        newdomain = 'test' + transform.unique('test')
        self.assertEqual(True, transform.checkunique(newdomain, 1),
                         'init new domain')
        self.assertEqual(False, transform.checkunique(newdomain, 1),
                         'seq should be 2')
        self.assertEqual(False, transform.checkunique(newdomain, 3),
                         'seq should be 2')
        self.assertEqual(True, transform.checkunique(newdomain, 2), 'next one')
        self.assertEqual(True, transform.checkunique(newdomain, 3), 'next one')
        self.assertEqual(True, transform.checkunique(newdomain, 4), 'next one')
        self.assertEqual(False, transform.checkunique(newdomain, 4),
                         'next one')
        self.assertEqual(False, transform.checkunique(newdomain, 6),
                         'next one')
        self.assertEqual(True, transform.checkunique(newdomain, 5), 'next one')

        newdomain = 'test' + transform.unique('test')
        self.assertEqual('1', transform.unique(newdomain), 'init new domain')
        self.assertEqual('1', transform.unique(newdomain, updatewith=999),
                         'init new domain')
        self.assertEqual('999', transform.unique(newdomain, updatewith=9999),
                         'init new domain')
        self.assertEqual('9999', transform.unique(newdomain, updatewith=9999),
                         'init new domain')
        self.assertEqual('9999',
                         transform.unique(newdomain, updatewith=20140404),
                         'init new domain')
        self.assertEqual('20140404',
                         transform.unique(newdomain, updatewith=20140405),
                         'init new domain')
        self.assertEqual('20140405',
                         transform.unique(newdomain, updatewith=20140406),
                         'init new domain')
        self.assertEqual('20140406',
                         transform.unique(newdomain, updatewith=20140407),
                         'init new domain')
        self.assertEqual('20140407',
                         transform.unique(newdomain, updatewith=20140408),
                         'init new domain')
Esempio n. 10
0
    def testunique(self):
        newdomain = "test" + transform.unique("test")
        self.assertEqual("1", transform.unique(newdomain), "init new domain")
        self.assertEqual("2", transform.unique(newdomain), "next one")
        self.assertEqual("3", transform.unique(newdomain), "next one")
        self.assertEqual("4", transform.unique(newdomain), "next one")

        newdomain = "test" + transform.unique("test")
        self.assertEqual(True, transform.checkunique(newdomain, 1),
                         "init new domain")
        self.assertEqual(False, transform.checkunique(newdomain, 1),
                         "seq should be 2")
        self.assertEqual(False, transform.checkunique(newdomain, 3),
                         "seq should be 2")
        self.assertEqual(True, transform.checkunique(newdomain, 2), "next one")
        self.assertEqual(True, transform.checkunique(newdomain, 3), "next one")
        self.assertEqual(True, transform.checkunique(newdomain, 4), "next one")
        self.assertEqual(False, transform.checkunique(newdomain, 4),
                         "next one")
        self.assertEqual(False, transform.checkunique(newdomain, 6),
                         "next one")
        self.assertEqual(True, transform.checkunique(newdomain, 5), "next one")

        newdomain = "test" + transform.unique("test")
        self.assertEqual("1", transform.unique(newdomain), "init new domain")
        self.assertEqual("1", transform.unique(newdomain, updatewith=999),
                         "init new domain")
        self.assertEqual("999", transform.unique(newdomain, updatewith=9999),
                         "init new domain")
        self.assertEqual("9999", transform.unique(newdomain, updatewith=9999),
                         "init new domain")
        self.assertEqual(
            "9999",
            transform.unique(newdomain, updatewith=20_140_404),
            "init new domain",
        )
        self.assertEqual(
            "20140404",
            transform.unique(newdomain, updatewith=20_140_405),
            "init new domain",
        )
        self.assertEqual(
            "20140405",
            transform.unique(newdomain, updatewith=20_140_406),
            "init new domain",
        )
        self.assertEqual(
            "20140406",
            transform.unique(newdomain, updatewith=20_140_407),
            "init new domain",
        )
        self.assertEqual(
            "20140407",
            transform.unique(newdomain, updatewith=20_140_408),
            "init new domain",
        )