def test022(self): oldList = list(1, 100) add('大学英语', '大学英语课程', '4') newList = list(1, 100) self.assertEqual( len(oldList['retlist']) + 1, len(newList['retlist']), '新增失败') print('22新增成功')
def sendCourseReq(row): # print(row) # 传入的是一行数据,也就是一个测试用例 colus5 = row[4] #第5列的值 # 第6列的值,用json.loads方法,把字符串转化为字典格式 colus6 = json.loads(row[5]) ret = None if colus5 == 'add': # print(colus6['name'])# 课程名称 courseName = colus6['name'] # 获取课程名称 # 把关键字:{{courseName}} 替换成时间戳 courseName = courseName.replace('{{courseName}}', str(int(time.time() * 100))) ret = add(courseName, colus6['desc'], colus6['display_idx']) elif colus5 == 'list': ret = list(colus6['pagenum'], colus6['pagesize']) elif colus5 == 'delete': ret = delete(colus6['id']) return ret # path='E:\ProjectCodeForPy\APIAutoTest20200422\data\教管系统-测试用例V1.2.xls' # # excelCases=redExcel(path,0) # # sendCourseReq(excelCases[0]) # print(excelCases)
def test003(self): courseName = "大学英语" + str(int(time.time() * 10000)) # 1-1 先列出课程 retList0 = list(1, 400) # 1-2 再新增课程 ret = add(courseName, '课程描述', '0') print(ret) #1-3 断言1 self.assertEqual(ret['retcode'] ,0,'新增课程失败1') print(">>>>>新增课程测试通过1") # 1-4 再次列出课程 retList1 = list(1, 400) #1-5 断言2 self.assertEqual(retList0['total'] + 1,retList1['total'],'新增课程失败2') print(">>>>>新增课程测试通过3")
def test01(self): courseName = '初中化学' + str(int(time.time() * 10000)) retDict = add(courseName, 'sdfdss', 0) self.assertEqual(retDict['retcode'], 0, '测试不通过xxxxx') id = retDict['id'] # 2.调用列出课程接口,查看新增的课程是否存在 retDict2 = list(1, 500) # print(retDict2['retlist']) exit2 = 0 for item in retDict2['retlist']: if id == item['id']: exit2 = 10 break self.assertEqual(exit2, 10) print('测试通过')
def sendCourseReq(row): colus5 = json.loads(row[5]) # 请求参数 retDict = '' if (row[4] == 'add'): # 新增课程 courseName = colus5['name'] courseName = courseName.replace('{{courseName}}', '大学物理' + str(int(time.time() * 1000))) retDict = add(courseName, colus5['desc'], colus5['display_idx']) elif (row[4] == 'delete'): # 删除课程 retDict = delete(colus5['id']) elif (row[4] == 'list'): # 列出课程 retDict = list(colus5['pagenum'], colus5['pagesize']) elif (row[4] == 'modidfy'): # 修改课程 pass else: pass return retDict
from lib.courseLib import add,list oldList = list(1,100) ret = add('大学英语','大学英语课程','4') newList = list(1,100) if len(oldList['retlist']) == len(newList['retlist']): print('没有刚刚新增的课程') else: print('刚刚有新增成功课程')
from lib.courseLib import add, list import time courseName = "大学英语" + str(int(time.time() * 10000)) #1-1 再新增课程 ret = add(courseName, '课程描述', '0') print(ret) if ret['retcode'] == 0: print(">>>>>新增课程测试通过1") #1-2 列出课程 retList1 = list(1, 400) isExit = True for data in retList1['retlist']: # print(data) if ret['id'] == data['id']: print('>>>>>>新增课程测试通过2') isExit = False break if isExit: print('>>>>>>>测试不通过,列表中不存在')
from lib.courseLib import add,list import time courseName = '大学物理'+str(int(time.time()*1000)) ret = add(courseName,'大学物理',0) returnList = list(1,1000) have = False for msg in returnList['retlist']: # print(msg) if ret['id'] == msg['id']: print('新增课程测试成功') have = True break if have == False: print('新增课程失败')
from lib.courseLib import add, list import time #1.新增一个系统中不存在的课程 courseName = '初中化学' + str(int(time.time() * 10000)) retDict9 = add(courseName, 'sdfdss', 0) # 再次新增一样的课程 retDict = add(courseName, 'sdfdss', 0) print(retDict) if retDict['retcode'] == 2: print('>>>>>新增同名课程测试通过') #2.调用列出课程接口,查看新增的课程是否存在 retDict2 = list(1, 500) # print(retDict2['retlist']) exit2 = 0 for item in retDict2['retlist']: if courseName == item['name']: exit2 = exit2 + 1 if exit2 > 1: print('>>>>>列出课程测试不通过') elif exit2 == 1: print('>>>>>列出课程测试通过') else: print('>>>>>>测试不通过')