Beispiel #1
0
    def test_eticket_check_exist(self):
        code = random.randint(1, 1000000)

        add_url = 'http://{ip}:8300/eticket/add?code={code}'.format(ip=SERVER_IP, code=code)
        add_url = append_url_sign_tk(add_url, gen_tk(), API_SECRET)
        add_res = json.loads(urllib2.urlopen(urllib2.Request(add_url)).read())
        add_status = add_res['status']
        print add_res
        self.assertTrue(add_status == 0)

        check_url = 'http://{ip}:8300/eticket/check?code={code}'.format(ip=SERVER_IP, code=code)
        check_url = append_url_sign_tk(check_url, gen_tk(), API_SECRET)
        print check_url
        check_res = json.loads(urllib2.urlopen(urllib2.Request(check_url)).read())
        print check_res
        check_status = check_res['status']
        self.assertTrue(check_status == 0)
Beispiel #2
0
def get_list():
    cls_ls = get_cls()
    print cls_ls
    select_cls = random.choice(cls_ls)['id']
    album_ls = get_album(select_cls)
    print album_ls
    select_album = random.choice(album_ls)['id']

    url = 'http://{ip}:8300/audio/list?album_id={album_id}'.format(ip=SERVER_IP, album_id=select_album)
    url = append_url_sign_tk(url, gen_tk(), API_SECRET)
    print url
    return json.loads(urllib2.urlopen(urllib2.Request(url)).read())
Beispiel #3
0
    def test_chat_msg_bcast(self):
        file_type = "3"
        fn = "yT08JbAAQP3zcrAscxJ0-F0QjYhYy06PRre1jD-5B6_GJaV1gt1uzE9ELYQmPJcG.amr"
        ref = "88ded5a264996f38881538c1bf47be6cce05deb04dd5cd0eb359b8ea6d1f3dd27f5fc023ba19cc35cc2f7331a8f1cdcc24b148e47367e9b797dd46ccdda1c5442d21398f9c5983da68c92f7b3c039e267aca333ef21d38d19a3456351b65c0cbbf5aa36537733a6afb26dcb1e8e2486869c1691d53cab33ff3284f823a9df9ddac81d7beac"

        url = 'http://{ip}:8300/chat/bcast?file_type={ftype}&fn={fn}&ref={ref}'.format(
            ip=SERVER_IP,
            ftype=urllib2.quote(file_type),
            fn=urllib2.quote(fn),
            ref=urllib2.quote(ref))
        url = append_url_sign_tk(url, gen_tk(), API_SECRET)
        print url

        urllib2.urlopen(urllib2.Request(url)).read()

        global APIChatMsgBcastTestHdl
        APIChatMsgBcastTestHdl = self
        self.wait(timeout=5)
Beispiel #4
0
    def test_pub_2_dev(self):
        audio_ls = get_list()
        print audio_ls
        select_audio = random.choice(audio_ls)

        sn ="PNZHANCHENJIN"

        url = 'http://{ip}:8300/audio/pub_2_dev?dev_sn={sn}&name={name}&ref={ref}'.format(
            ip=SERVER_IP,
            sn=urllib2.quote(sn),
            name=urllib2.quote(select_audio['name']),
            ref=urllib2.quote(select_audio['ref']))
        url = append_url_sign_tk(url, gen_tk(), API_SECRET)
        print url

        urllib2.urlopen(urllib2.Request(url)).read()

        global APIAudioSend2DevTestHdl
        APIAudioSend2DevTestHdl = self
        self.wait(timeout=5)
    def test_audio_ai(self):
        wav_file = r"C:\Users\151117a\Desktop\res\iflytek02.wav".decode('utf8')
        file_object = open(wav_file, 'rb')
        file_data = file_object.read()
        fn = wav_file.split('\\')[-1]
        print "fn,", fn
        print len(file_data)
        stime = time.time()
        beiqi_ref = up_beiqi_file(TEST_USER_NAME, 3, fn, file_data,
                                  'http://{ip}:8106/up?'.format(ip=SERVER_IP))
        print "beiqi_ref,", beiqi_ref

        ai_url = 'http://{ip}:8300/audio/ai?fn={fn}&ref={ref}'.format(
            ip=SERVER_IP, fn=fn, ref=urllib2.quote(beiqi_ref))
        ai_url = append_url_sign_tk(ai_url, gen_tk(), API_SECRET)
        print "ai_url,", ai_url

        resp = urllib2.urlopen(urllib2.Request(ai_url)).read()
        resp = json.loads(resp)

        etime = time.time()
        print "diff time:%s" % (etime - stime)
        print "resp,", resp

        ai_data = down_beiqi_file(
            TEST_USER_NAME, resp['fn'], resp['ref'],
            'http://%s:8106/down?tk={tk}&r={ref}' % SERVER_IP)
        mp3file = r"C:\Users\151117a\Desktop\res\%s" % resp['fn']
        print mp3file
        file_object = open(mp3file, 'wb')
        file_object.write(ai_data)
        file_object.close()

        etime = time.time()
        print "diff time:%s" % (etime - stime)
        print "resp,", resp
Beispiel #6
0
def get_album(cls_id):
    url = "http://{ip}:8300/audio/album?cls_id={cls_id}".format(ip=SERVER_IP, cls_id=urllib2.quote(cls_id.encode('utf-8')))
    url = append_url_sign_tk(url, gen_tk(), API_SECRET)
    print url
    return json.loads(urllib2.urlopen(urllib2.Request(url)).read())
Beispiel #7
0
def get_cls():
    url = 'http://{ip}:8300/audio/cls'.format(ip=SERVER_IP)
    url = append_url_sign_tk(url, gen_tk(), API_SECRET)
    print url
    return json.loads(urllib2.urlopen(urllib2.Request(url)).read())