コード例 #1
0
    def test_video_download(self, filefortest1):
        file_id = base.get_file_id(base.file_upload_url(), filefortest1)
        print('CCCCCCCCCCCCCCCCCCC')
        print(file_id)

        params = {'id': file_id, 'format': 'pdf'}
        DataAll1 = {'params': params}
        r1 = HttpService.MyHTTP(self.url1).nojsonget(self.url1, **DataAll1)
        date1 = r1.headers
        print(date1['Content-Disposition'])
        r1_content = date1['Content-Disposition']
        bool_endwith1 = r1_content.endswith('.pdf')
        print(bool_endwith1)

        params = {'id': file_id, 'format': 'thumbnail'}
        DataAll2 = {'params': params}
        r1 = HttpService.MyHTTP(self.url1).nojsonget(self.url1, **DataAll2)
        date1 = r1.headers
        print(date1['Content-Disposition'])
        r1_content = date1['Content-Disposition']
        bool_endwith2 = r1_content.endswith('.jpg')
        print(bool_endwith2)

        self.assertEqual(bool_endwith1, True)
        self.assertEqual(bool_endwith2, True)

        def tearDown(self):
            print('Test Over')
コード例 #2
0
ファイル: base.py プロジェクト: pod1019/python_learning
def get_response(url,Method,**DataALL):
    resp = None
    if Method =='get':
        resp = HttpService.MyHTTP().get(url,**DataALL)
    elif Method == 'post':
        resp = HttpService.MyHTTP().post(url,**DataALL)
    return resp
コード例 #3
0
ファイル: base.py プロジェクト: weijianhui011/uploadfile
def get_response(url, method, **dataall):
    myhttp=HttpService.MyHTTP(url)
    if method == 'get':
        resp = myhttp.get(url,**dataall)
    if method == 'post':
        resp = myhttp.post(url, **dataall)
    return (resp)
コード例 #4
0
 def test_post_data2(self):
     params = {'show_env': 1}
     data = {'a': '巧吧软件测试', 'b': 'form-data'}
     DataAll = {'params': params, 'data': data}
     resp = HttpService.MyHTTP().post(self.url, **DataAll)
     form = resp.get('form').get('a')
     self.assertIsInstance(form, str)
コード例 #5
0
    def test_post_params(self, file_for_test):
        #上传一个文件判断是否上传成功
        #os.chdir(Config.uploadpath())
        os.chdir(Config.upload_path)
        file_name_in_folder = file_for_test
        md5code = base.get_file_md5(file_name_in_folder)
        print(md5code)
        headers = {'nb-file-md5': md5code}
        files = {
            'field1': (file_name_in_folder, open(file_name_in_folder, 'rb'))
        }

        data_all = {'headers': headers, 'files': files}

        r = HttpService.MyHTTP(self.url).post(self.url, **data_all)
        #roo = requests.post(self.url,headers = headers,files = files)
        #r = roo.json()
        print(r)
        file_id = r.get('Data')
        print(file_id)
        connect = r.get('Success')
        msg = r.get("Message")
        print(connect)

        md5Indb = base.md5_from_sql(str(file_id))[0][0]
        print(md5Indb)

        self.assertEqual(connect, True)
        self.assertEqual(msg, "上传成功")
        self.assertEqual(md5code, md5Indb)
        files['field1'][1].close()
コード例 #6
0
 def test_post_data1(self):
     params = {'show_env': 1}
     data = {'a': '巧吧软件测试', 'b': 'form-data'}
     DataAll = {'params': params, 'data': data}
     resp = HttpService.MyHTTP().post(self.url, **DataAll)
     # r=requests.post(self.url,params=params,data=data)
     # resp=r.json()
     self.assertEqual(resp["form"]['a'], '巧吧软件测试')
コード例 #7
0
ファイル: base.py プロジェクト: weijianhui011/uploadfile
def get_file_id(url, file):
    os.chdir(Config.upload_path)
    print(os.getcwd)
    file_name_in_folder = file
    md5code = get_file_md5(file_name_in_folder)
    headers = {'nb-file-md5': md5code}
    files = {'field1': (file_name_in_folder, open(file_name_in_folder, 'rb'))}
    data_all = {'headers': headers, 'files': files}
    r = HttpService.MyHTTP(url).post(url, **data_all)
    file_id = r.get('Data')
    files['field1'][1].close()
    return file_id
コード例 #8
0
def test_video_download():
    num= random.randint(1,10000)
    headers= {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.08 (KHTML, like Gecko) Chrome/%d.0.3359.117 Safari/537.36'%num}
   # headers = {'nb-file-md5': md5code}
    #print(headers)
    file_id ='efef4642-160b-4404-aa94-6f2930773814'
    url1 = 'http://192.168.1.101:9999/nbfile/Fetch'
    params = {'id': file_id, 'format': 'mp4'}
    DataAll1 = {'headers':headers,'params': params}
    r1 = HttpService.MyHTTP(url1).nojsonget(url1, **DataAll1)

    #date1 = r1.headers
    #print(date1['Content-Disposition'])
    #r1_content = date1['Content-Disposition']
    #bool_endwith1 = r1_content.endswith('.mp4')
    #print(bool_endwith1)
    r1.close()
コード例 #9
0
    def test_get_params2(self):
        #
        #
        params = {"show_env": 2}

        DataALL = {'params': params}

        #给服务器发送请求

        #         r=requests.get(self.url,params=parmers)
        #
        #         resp = r.json()

        resp = HttpService.MyHTTP().get(self.url, **DataALL)

        connect = resp.get('headers').get('Host')

        self.assertIsInstance(connect, str)
コード例 #10
0
    def test_post_params(self, result):
        #上传一个文件判断是否上传成功
        os.chdir(Config.uploadpath())
        print(os.getcwd)

        md5code = base.getfilemd5('1.pdf')
        headers = {'nb-file-md5': md5code}
        files = {'field1': ('1.pdf', open('1.pdf', 'rb'))}
        DataAll = {'headers': headers, 'files': files}

        r = HttpService.MyHTTP(self.url).post(self.url, **DataAll)
        #roo = requests.post(self.url,headers = headers,files = files)
        #r = roo.json()
        print(r)
        connect = r.get('Success')
        msg = r.get("Message")
        print(connect)
        self.assertEqual(connect, result)
        self.assertEqual(msg, "上传成功")
コード例 #11
0
    def test_get_params(self):

        params = {"show_env": 1}

        DataALL = {'params': params}

        #给服务器发送请求

        #         r=requests.get(self.url,params=parmers)
        #
        #         resp = r.json()

        resp = HttpService.MyHTTP().get(self.url, **DataALL)

        #        resp1= json.dumps(resp, encoding="UTF-8", ensure_ascii=False)

        #         print resp1

        connect = resp.get('headers').get('Host')
        self.assertEqual(connect, 'httpbin.org')
コード例 #12
0
    def test_params_headers(self):

        params = {"show_env": 1}

        header = {
            'Connection': 'keep-alive',
            'Accept-Encoding': 'gzip, deflate',
            'Accept': '*/*',
            'User-Agent': 'python-requests/2.21.0'
        }

        DataALL = {'params': params, 'headers': header}

        #       r=requests.get(self.url,params=params,headers=header)
        #
        #       resp = r.json()

        #       resp = HttpService.MyHTTP().get(self.url, params)

        resp = HttpService.MyHTTP().get(self.url, **DataALL)

        connect = resp.get('headers').get('Host')

        self.assertEqual(connect, 'httpbin.org')