1. 程式人生 > 其它 >驗證我的數字元件,列表翻頁功能支援指令碼

驗證我的數字元件,列表翻頁功能支援指令碼

#coding:utf-8
import unittest,requests,time

class PublishDigitalDocuments(unittest.TestCase):
    '''數字元件釋出'''
    def test_01(self):
        '''數字元件釋出'''
        for i in range(0,100):
            componentName = "test" + str(time.time())[-7:]
            print(componentName)
            payload1 = {
                
"componentLabel": ["D001"], "componentName": componentName, "componentType": "D010", "componentValue": "{\"cid\":\"compId-x\",\"type\":\"component\",\"title\":\"元件名稱\",\"eCodes\":[\"ecode-a\",\"ecode-b\",\"ecode-c\",\"ecode-d\"],\"values\":[{\"ecode-a\":\"ecode-a 資料\"},{\"ecode-b\":\"ecode-b 資料\"},{\"ecode-c\":\"ecode-c 資料\"},{\"ecode-d\":\"ecode-d 資料\"}]}
", "enterpriseId": "1", "keywords": ["關鍵詞1","關鍵詞2","關鍵詞3","關鍵詞4","關鍵詞5"] } s = requests.session() #拼接請求地址 url_api = "xxx" #請求頭部 headers2 = { "Content-Type": "application/json", } r
= s.post(url=url_api,headers=headers2,json=payload1) print(r.json()) if __name__=="__main__": unittest.main()