def run(self): while True: gd = Getdata(host,port,user,pwd) v_list = gd.getdata() # print v_list # print sql_test2x sI = Sqldb(dbhost,dbuser,dbpwd,dbport,dbname) sI.sqlLogin() sI.instData(sql_test2x,v_list)
def run(self): while True: gD = Getdata(host,port,user,pwd) v_list = gD.getdata() vlist = v_list # print v_list sI = mysqldb() sI.sqlLogin(dbhost,dbuser,dbpwd,dbport,dbname,dbtable,vlist) sI.instData()
class Testlogin(): data = Getdata() username = data.getdata('data', 'username') pwd = data.getdata('data', 'password') address = data.getdata('data', 'address') def test_login(self, username=username, pwd=pwd, address=address): url = f"{address}/api/Access/Login" payload = f'userName={username}&userPwd={pwd}' headers = {'Content-Type': 'application/x-www-form-urlencoded'} response = requests.post(url, headers=headers, data=payload) print(response.json()) t = response.json()['result']['token'] # token = {'token': t} self.data.send_data('token', 'token', t) assert response.status_code == 200 def test_loginout(self): url = f"{self.address}/api/Access/LogOut" response = requests.request("GET", url) assert response.status_code == 200
def setup(self): self.data = Getdata() self.token = self.data.getdata('token', 'token') self.address = self.data.getdata('data', 'address')
class TestGetmenu: def setup(self): self.data = Getdata() self.token = self.data.getdata('token', 'token') self.address = self.data.getdata('data', 'address') #self.areaid=self.data.getdata('areaid','area_id') # 获取所有已交付地点area_id def test_getarea_id(self): url = f"{self.address}/api/BasicData/getAllDeliveryAreas" payload = {} headers = { 'X-Token': f'{self.token}', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("GET", url, headers=headers, data=payload) id = response.json()['result']['data'] ids = [] for i in range(len(id)): areaid = id[i]['id'] ids.append(areaid) self.data.send_data('areaid', 'area_id', ids) print(response.json()) assert response.status_code == 200 #根据id获取酒店名称 def getarea_name(self, areaid): url = f"{self.address}/api/cloud/Areas/getAreaInfo" payload = f'area_id={areaid}' headers = { 'X-Token': f'{self.token}', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) return response.json()['result']['data']['basic']['area_name'] # 根据id获取当天明细报表任务 # areaid = Getdata.getdata('areaid', 'area_id') @pytest.mark.parametrize('areaid', Getdata.getdata('', 'areaid', 'area_id')) def test_getdetail(self, areaid): begindate = "2020-12-25" enddate = "2020-12-29" url = f"{self.address}/api/cloud/RunLog/getDetailRunLogs" payload = f'begin_date={begindate}&end_date={enddate}&area_id={areaid}' headers = { 'X-Token': f'{self.token}', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) print(response.json()) #统计任务类型 if (len(response.json()['result']['data']) <= 0): print(f"{self.getarea_name(areaid)}在{begindate}号到{enddate}号没有任务") assert response.status_code == 200 assert response.json()['result']['data'] != 0 #判断明细报表中所有已交付地点都有数据 @pytest.mark.parametrize('areaid', Getdata.getdata('', 'areaid', 'area_id')) def test_getalldetail(self, areaid): begindate = "2020-12-29" enddate = "2020-12-29" url = f"{self.address}/api/cloud/RunLog/getDetailRunLogs" payload = f'begin_date={begindate}&end_date={enddate}&area_id={areaid}' headers = { 'X-Token': f'{self.token}', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) print(response.json()) data = response.json()['result']['data'] # 统计任务类型 if (len(data) <= 0): print(f"{self.getarea_name(areaid)}在{begindate}到{enddate}期间没有任务") else: map = {} result = {} for i in range(len(data)): item = data[i] key = item['run_type'] if (map.get(key)): map[key] += 1 else: map[key] = 1 for i in range(len(data)): item = data[i] key = item['run_result'] if (result.get(key)): result[key] += 1 else: result[key] = 1 print(f'任务类型:数量:{map},任务状态:数量:{result}') assert response.status_code == 200
# 准备配置文件 conf = ConfigParser.ConfigParser() conf.read("7liping-data.cfg") # 设备的配置数据 host = conf.get('device1', 'host') port = string.atoi(conf.get('device1', 'port')) user = conf.get('device1', 'user') pwd = conf.get('device1', 'password') # 数据库的配置数据 dbhost = conf.get('db_mysql', 'host') dbport = (conf.get('db_mysql', 'port')) dbuser = conf.get('db_mysql', 'user') dbpwd = conf.get('db_mysql', 'password') dbname = conf.get('db_mysql', 'db') dbtable = conf.get('db_mysql','table') gD = Getdata(host,port,user,pwd) v_list = gD.getdata() vlist = v_list # print v_list sI = Sqldb(dbhost,dbuser,dbpwd,dbport,dbname,dbtable,vlist) sI.sqlLogin() sI.instData()
orient=HORIZONTAL, length=200, mode='determinate', max=60) progress.pack(padx=30, pady=10) Listbox_sits = Listbox(master, width=40) Listbox_sits.pack(side="left", fill=Y) scrollbar = Scrollbar(master, orient="vertical", command=Listbox_sits.yview) scrollbar.pack(side="right", fill=Y) Listbox_sits.pack() Listbox_sits.config(yscrollcommand=scrollbar.set) getdata = Getdata() def main_Frame(): button_get_sites.configure(command=Get_sites) # <Double-1> for double click Listbox_sits.bind('<Double-1>', onselect) file = 'sites_data.xlsx' global workbook if os.path.exists(file): workbook = openpyxl.load_workbook(file) else: workbook = openpyxl.Workbook()
conf.read("7liping-data.cfg") # 设备的配置数据 host = conf.get('device1', 'host') port = string.atoi(conf.get('device1', 'port')) user = conf.get('device1', 'user') pwd = conf.get('device1', 'password') # 数据库的配置数据 dbhost = conf.get('db_mysql', 'host') dbport = (conf.get('db_mysql', 'port')) dbuser = conf.get('db_mysql', 'user') dbpwd = conf.get('db_mysql', 'password') dbname = conf.get('db_mysql', 'db') dbtable = conf.get('db_mysql','table') while True: gd = Getdata(host,port,user,pwd) v_list = gd.getdata() print v_list # sI = Sqlinsert(dbhost,dbuser,dbpwd,dbport,dbname,dbtable,v_list) # sI.sqlinsert() # def __init__(self,r1Host="124.161.108.46",r1Port=20001,r1User="******",r1Pwd="api",cmd=""): # self.r1Host=r1Host # self.r1Port=r1Port # self.r1User=r1User # self.r1Pwd=r1Pwd # # def getdata(self): # '''从rosAPI获取数据''' # api1 = Core(self.r1Host, self.r1Port) # api1.login(self.r1User, self.r1Pwd)