test_add_job.py 1.17 KB
import unittest
from atdd.PcPost import PcPost
import random


class AddJob(PcPost):
    name = random.randint(1, 10000)
    url = '/Contact/Apicp/Job/Add'

    def setUp(self):
        self.do_login(self.host, self.mobile, self.psw, self.domain)

    # 正常添加岗位信息
    def test_addjob(self):
        data = {
            'jobName': 'AddJobApi' + str(self.name)  # 如何动态读取
        }
        result = self.PcPost(self.url, data)
        print('接口地址:' + self.host + self.domain + self.url)
        jobId = result['result']['jobId']
        print('成功生成岗位!岗位ID:' + jobId)
        # self.assertEqual(jobId, , msg='成功生成测试jobId')  # 如何判断生成的Jobid
        return result

    # 岗位名称超过20个汉字
    def test_addjob_namelen(self):
        url = '/Contact/Apicp/Job/Add'
        data = {
            'jobName': '新增岗位接口,测试岗位名称超过20个汉字' + str(self.name)
        }
        result = self.PcPost(self.url, data)
        jobId = result['result']['jobId']
        print('成功生成岗位!岗位ID:' + jobId)
        return result

if __name__ == '__main__':
    unittest.main()