Exemple #1
4
def test_ccode_with_unicode():
    domein = 'test'
    tests = [(u'key1',u'leftcode'),
            (u'key2',u'~!@#$%^&*()_+}{:";][=-/.,<>?`'),
            (u'key3',u'?érýúíó?ás??lzcn?'),
            (u'key4',u'?ë?ÿüïöä´¨???è?ùì'),
            (u'key5',u'òà???UIÕÃ?Ñ`~'),
            (u'key6',u"a\xac\u1234\u20ac\U00008000"),
            (u'key7',u"abc_\u03a0\u03a3\u03a9.txt"),
            (u'key8',u"?ÉRÝÚÍÓ?ÁS??LZCN??"),
            (u'key9',u"Ë?¨YܨIÏÏÖÄ???È?ÙÌÒ`À`Z?"),
            ]
    try:    #clean before test
        botslib.changeq(u'''DELETE FROM ccode ''')
        botslib.changeq(u'''DELETE FROM ccodetrigger''')
    except:
        print 'Error while deleting: ',botslib.txtexc()
        raise
    try:
        botslib.changeq(u'''INSERT INTO ccodetrigger (ccodeid)
                                VALUES (%(ccodeid)s)''',
                                {'ccodeid':domein})
        for key,value in tests:
            botslib.changeq(u'''INSERT INTO ccode (ccodeid_id,leftcode,rightcode,attr1,attr2,attr3,attr4,attr5,attr6,attr7,attr8)
                                    VALUES (%(ccodeid)s,%(leftcode)s,%(rightcode)s,'1','1','1','1','1','1','1','1')''',
                                    {'ccodeid':domein,'leftcode':key,'rightcode':value})
    except:
        print 'Error while updating: ',botslib.txtexc()
        raise
    try:
        for key,value in tests:
            print 'key',key
            for row in botslib.query(u'''SELECT rightcode
                                        FROM    ccode
                                        WHERE   ccodeid_id = %(ccodeid)s
                                        AND     leftcode = %(leftcode)s''',
                                        {'ccodeid':domein,'leftcode':key}):
                print '    ',key, type(row['rightcode']),type(value)
                if row['rightcode'] != value:
                    print 'failure in test "%s": result "%s" is not equal to "%s"'%(key,row['rightcode'],value)
                else:
                    print '    OK'
                break;
            else:
                print '??can not find testentry %s %s in db'%(key,value)
    except:
        print 'Error while quering db: ',botslib.txtexc()
        raise
Exemple #2
0
def change_communication_type(idchannel, to_type):
    botslib.changeq(
        u'''UPDATE channel
                        SET type = %(to_type)s
                        WHERE idchannel = %(idchannel)s
                        ''', {
            'to_type': to_type,
            'idchannel': idchannel
        })
Exemple #3
0
def change_communication_type(idchannel, to_type):
    botslib.changeq(
        """UPDATE channel
                        SET type = %(to_type)s
                        WHERE idchannel = %(idchannel)s
                        """,
        {
            "to_type": to_type,
            "idchannel": idchannel
        },
    )
Exemple #4
0
def indicate_rereceive():
    count = 0
    for row in botslib.query(u'''SELECT idta
                            FROM    filereport
                            ORDER BY idta DESC
                            '''):
        count += 1
        botslib.changeq(u'''UPDATE filereport
                            SET retransmit = 1
                            WHERE idta=%(idta)s
                            ''', {'idta': row[str('idta')]})
        if count >= 2:
            break
Exemple #5
0
def indicate_rereceive():
    count = 0
    for row in botslib.query(u'''SELECT idta
                            FROM    filereport
                            ORDER BY idta DESC
                            '''):
        count += 1
        botslib.changeq(u'''UPDATE filereport
                            SET retransmit = 1
                            WHERE idta=%(idta)s
                            ''',{'idta':row[str('idta')]})
        if count >= 2:
            break
Exemple #6
0
def indicate_send():
    count = 0
    for row in botslib.query(u'''SELECT idta
                            FROM    ta
                            WHERE status=%(status)s
                            ORDER BY idta DESC
                            ''', {'status': EXTERNOUT}):
        count += 1
        botslib.changeq(u'''UPDATE ta
                            SET retransmit = %(retransmit)s
                            WHERE idta=%(idta)s
                            ''', {'retransmit': True, 'idta': row[str('idta')]})
        if count >= 2:
            break
Exemple #7
0
def indicate_send():
    count = 0
    for row in botslib.query(u'''SELECT idta
                            FROM    ta
                            WHERE status=%(status)s
                            ORDER BY idta DESC
                            ''',{'status':EXTERNOUT}):
        count += 1
        botslib.changeq(u'''UPDATE ta
                            SET retransmit = %(retransmit)s
                            WHERE idta=%(idta)s
                            ''',{'retransmit':True,'idta':row[str('idta')]})
        if count >= 2:
            break
Exemple #8
0
def test_ccode_with_unicode():
    domein = 'test'
    tests = [
        (u'key1', u'leftcode'),
        (u'key2', u'~!@#$%^&*()_+}{:";][=-/.,<>?`'),
        (u'key3', u'?érýúíó?ás??lzcn?'),
        (u'key4', u'?ë?ÿüïöä´¨???è?ùì'),
        (u'key5', u'òà???UIÕÃ?Ñ`~'),
        (u'key6', u"a\xac\u1234\u20ac\U00008000"),
        (u'key7', u"abc_\u03a0\u03a3\u03a9.txt"),
        (u'key8', u"?ÉRÝÚÍÓ?ÁS??LZCN??"),
        (u'key9', u"Ë?¨YܨIÏÏÖÄ???È?ÙÌÒ`À`Z?"),
    ]
    try:  #clean before test
        botslib.changeq(u'''DELETE FROM ccode ''')
        botslib.changeq(u'''DELETE FROM ccodetrigger''')
    except:
        print('Error while deleting: ', botslib.txtexc())
        raise
    try:
        botslib.changeq(
            u'''INSERT INTO ccodetrigger (ccodeid)
                                VALUES (%(ccodeid)s)''', {'ccodeid': domein})
        for key, value in tests:
            botslib.changeq(
                u'''INSERT INTO ccode (ccodeid_id,leftcode,rightcode,attr1,attr2,attr3,attr4,attr5,attr6,attr7,attr8)
                                    VALUES (%(ccodeid)s,%(leftcode)s,%(rightcode)s,'1','1','1','1','1','1','1','1')''',
                {
                    'ccodeid': domein,
                    'leftcode': key,
                    'rightcode': value
                })
    except:
        print('Error while updating: ', botslib.txtexc())
        raise
    try:
        for key, value in tests:
            print('key', key)
            for row in botslib.query(
                    u'''SELECT rightcode
                                        FROM    ccode
                                        WHERE   ccodeid_id = %(ccodeid)s
                                        AND     leftcode = %(leftcode)s''', {
                        'ccodeid': domein,
                        'leftcode': key
                    }):
                print('    ', key, type(row[str('rightcode')]), type(value))
                if row[str('rightcode')] != value:
                    print(
                        'failure in test "%s": result "%s" is not equal to "%s"'
                        % (key, row['rightcode'], value))
                else:
                    print('    OK')
                break
            else:
                print('??can not find testentry %s %s in db' % (key, value))
    except:
        print('Error while quering db: ', botslib.txtexc())
        raise
Exemple #9
0
def main(inn,out):
     transform.inn2out(inn,out)          #997 is 'copied' as output, gets formatted as xmlnocheck)
     reference = inn.get({'BOTSID':'ST'},{'BOTSID':'AK1','AK102':None})
     #~ print reference,inn.ta_info['frompartner'],inn.ta_info['topartner']
     botslib.changeq('''UPDATE ta
                        SET   confirmed=%(confirmed)s, confirmidta=%(confirmidta)s
                        WHERE reference=%(reference)s
                        AND   status=%(status)s
                        AND   confirmasked=%(confirmasked)s
                        AND   confirmtype=%(confirmtype)s
                        AND   frompartner=%(frompartner)s
                        AND   topartner=%(topartner)s
                        ''',
                         {'status':MERGED,'reference':reference,'confirmed':True,'confirmtype':'ask-x12-997','confirmidta':inn.ta_info['idta_fromfile'],
                         'confirmasked':True,'frompartner':inn.ta_info['topartner'],'topartner':inn.ta_info['frompartner']})
Exemple #10
0
def indicate_rereceive():
    count = 0
    for row in botslib.query("""SELECT idta
                            FROM    filereport
                            ORDER BY idta DESC
                            """):
        count += 1
        botslib.changeq(
            """UPDATE filereport
                            SET retransmit = 1
                            WHERE idta=%(idta)s
                            """,
            {"idta": row[str("idta")]},
        )
        if count >= 2:
            break
def main(inn, out):
    out.ta_info['statust'] = DONE  #indicate: no output form translation.
    reference = inn.get({'BOTSID': 'ST'}, {'BOTSID': 'AK1', 'AK102': None})
    botslib.changeq(
        '''UPDATE ta
                       SET   confirmed=%(confirmed)s, confirmidta=%(confirmidta)s
                       WHERE reference=%(reference)s
                       AND   status=%(status)s
                       AND   confirmasked=%(confirmasked)s
                       AND   confirmtype=%(confirmtype)s
                       AND   frompartner=%(frompartner)s
                       AND   topartner=%(topartner)s
                       ''', {
            'status': MERGED,
            'reference': reference,
            'confirmed': True,
            'confirmtype': 'ask-x12-997',
            'confirmidta': inn.ta_info['idta_fromfile'],
            'confirmasked': True,
            'frompartner': inn.ta_info['topartner'],
            'topartner': inn.ta_info['frompartner']
        })
Exemple #12
0
def indicate_send():
    count = 0
    for row in botslib.query(
            """SELECT idta
                            FROM    ta
                            WHERE status=%(status)s
                            ORDER BY idta DESC
                            """,
        {"status": EXTERNOUT},
    ):
        count += 1
        botslib.changeq(
            """UPDATE ta
                            SET retransmit = %(retransmit)s
                            WHERE idta=%(idta)s
                            """,
            {
                "retransmit": True,
                "idta": row[str("idta")]
            },
        )
        if count >= 2:
            break
Exemple #13
0
def main(inn, out):
    transform.inn2out(
        inn, out)  #997 is 'copied' as output, gets formatted as xmlnocheck)
    reference = inn.get({'BOTSID': 'ST'}, {'BOTSID': 'AK1', 'AK102': None})
    #~ print reference,inn.ta_info['frompartner'],inn.ta_info['topartner']
    botslib.changeq(
        '''UPDATE ta
                        SET   confirmed=%(confirmed)s, confirmidta=%(confirmidta)s
                        WHERE reference=%(reference)s
                        AND   status=%(status)s
                        AND   confirmasked=%(confirmasked)s
                        AND   confirmtype=%(confirmtype)s
                        AND   frompartner=%(frompartner)s
                        AND   topartner=%(topartner)s
                        ''', {
            'status': MERGED,
            'reference': reference,
            'confirmed': True,
            'confirmtype': 'ask-x12-997',
            'confirmidta': inn.ta_info['idta_fromfile'],
            'confirmasked': True,
            'frompartner': inn.ta_info['topartner'],
            'topartner': inn.ta_info['frompartner']
        })
Exemple #14
0
def change_communication_type(idchannel, to_type):
    botslib.changeq(u'''UPDATE channel
                        SET type = %(to_type)s
                        WHERE idchannel = %(idchannel)s
                        ''', {'to_type': to_type, 'idchannel': idchannel})