get_jobid.py
1.08 KB
import unittest
from atdd.PcPost import PcPost
import random
class JobId(PcPost):
def setUp(self):
self.do_login(self.host, self.mobile, self.psw, self.domain)
# 获取岗位列表,从结果中提取所有jobId的值
def test_get_alljobid(self):
url = '/Contact/Apicp/Job/List'
data = {
}
result = self.PcPost(url, data)
resultlist = result['result']['list'] # 结果列表中的list信息
jobIdlist = [] # 创建空列表
for i in range(len(resultlist)): # 通过序列索引进行遍历 len返回元素个数
jobId = result['result']['list'][i]['jobId'].split() # 切片取出元素
jobIdlist[len(jobIdlist):len(jobIdlist)] = jobId
# print(jobIdlist)
return jobIdlist
def test_get_1jobid(self):
jobIdlist = self.test_get_alljobid()
x = random.randint(0, len(jobIdlist)-1) # 在所有jobID中随机取一个ID值
jobId = jobIdlist[x]
print("从列表中取一个jobId: " + jobId)
return jobId
if __name__ == '__main__':
unittest.main()