Interface Automation Architecture – 2

Get test cases

import xlrd


from lib.log import atp_log
class OpCase(object):
def get_case(self,file_path):
case
= []
if file_path.endswith('.xls') or file_path .endswith('.xlsx '):
try:
book
= xlrd.open_workbook(file_path)
sheet
= book.sheet_by_index(0)
for i in range(1, sheet.nrows ): # How many lines are there in excle
row_data = sheet.row_values(i) # Get the value of each row
case.append(row_data[4:8]) # slice (because only the Values ​​from subscript 4 to subscript 7)
atp_log.info('Total read %s use cases' % (len(case)))
except Exception as e:
atp_log.error(
'%s use case acquisition failed, error message% s' % (file_path, e))
else:
atp_log.error(
'The use case file is illegal: %s span>' % file_path)
return case

#Test
#
m = OpCase()
#
m.get_case(r'E:\Users\admin\PycharmProjects\Interface test\ATP')
#
m.get_case(‘xx.xls‘)
#
m.get_case(r'E:\Users\admin\PycharmProjects\Interface test\ATP\cases\test case.xlsx')< /span>

Send request

 def my_request(self,url,method,data):

method
= method.upper()
if method=='POST':
requests.get(url,params
=data)
else:
atp_log.warning(
'This request method is not currently supported')

import  xlrd


from lib.log import atp_log
class OpCase(object):
def get_case(self,file_path):
case
= []
if file_path.endswith('.xls') or file_path .endswith('.xlsx '):
try:
book
= xlrd.open_workbook(file_path)
sheet
= book.sheet_by_index(0)
for i in range(1, sheet.nrows ): # How many lines are there in excle
row_data = sheet.row_values(i) # Get the value of each row
case.append(row_data[4:8]) # slice (because only the Values ​​from subscript 4 to subscript 7)
atp_log.info('Total read %s use cases' % (len(case)))
except Exception as e:
atp_log.error(
'%s use case acquisition failed, error message% s' % (file_path, e))
else:
atp_log.error(
'The use case file is illegal: %s span>' % file_path)
return case

#Test
#
m = OpCase()
#
m.get_case(r'E:\Users\admin\PycharmProjects\Interface test\ATP')
#
m.get_case(‘xx.xls‘)
#
m.get_case(r'E:\Users\admin\PycharmProjects\Interface test\ATP\cases\Test Case.xlsx')< /span>

 def my_request(self, url,method,data):

method
= method.upper()
if method=='POST':
requests.get(url,params
=data)
else:
atp_log.warning(
'This request method is not currently supported')

Leave a Comment

Your email address will not be published.