def __update_message(self, number): """ 更新t_user_verify表信息 :param number: 用户手机号,从apiParams中获取 :return: """ result = self.db_server.query_one( "select * from t_user_verify where number ={}".format(number)) # 十分钟前的时间 timedelta = datetime.datetime.now() - datetime.timedelta(minutes=10) if not result: self.db_server.insert_data("t_user_verify", number=number, call_sid=generate_random_str(32), verify="123456", date_created=get_current_time(), status=1) return if result["date_created"] < timedelta: sql = "update t_user_verify set date_created='{}'where number={}". \ format(get_current_time(), number) self.db_server.update_data(sql) if result["status"] == 0: self.db_server.update_data( "update t_user_verify set status=1 where number={}".format( number))
def tearDown(self): self.driver.close() self.testCaseInfo.endtime = common.get_current_time() self.testCaseInfo.secondsDuration = common.get_time_diff( self.testCaseInfo.starttime, self.testCaseInfo.endtime) self.testReport.WriteHTML(self.testCaseInfo)
def begin_test(self): result_set = [] # 用例执行结果集 for case in self.cases: log.info("正在执行caseId为%s的用例" % case.get(CASEID)) result = Result() result.method = case.get(METHOD) result.time = get_current_time() result.apiHost = case.get(APIHOST) result.caseDescribe = case.get(CASEDESCRIBE) result.databaseExpect = case.get(DATABASEEXPECT) result.caseId = case.get(CASEID) result.apiParams = case.get(PARMAS) check_points = case[EXPECT] result.expect = check_points sqls = case[SQLSTATEMENT] sql_points = case[DATABASEEXPECT] test_data = case[TESTDATA] # 测试前提数据 self.__prapare_data(test_data) # 准备数据,执行sql或者shell # 请求接口 res = self.__excute_case(case) result.fact = res.get("response") # 验证检查点 self.__check_point(points=check_points, res=res, result=result) # 数据库检查 self.__check_sql(sql=sqls, sql_checks=sql_points, result=result) test_result = result.get_result() result_set.append(test_result) log.info("caseId为%s的用例完毕" % case.get(CASEID)) return result_set
def setUp(self): self.driver = webdriver.Chrome() self.base_url = 'http://www.taobao.com' self.testCaseInfo = TestCaseInfo(id='1', name=self.__str__(), owner='Oliver') self.testReport = TestReport() LogUtil.create_logger_file(__name__) self.testCaseInfo.starttime = common.get_current_time() LogUtil.log('Open base url: %s' % self.base_url)
def setUp(self): self.driver = webdriver.Chrome() # self.driver = webdriver.PhantomJS(service_args=SERVICE_ARGS) self.base_url = "http://selenium-python.readthedocs.io/" self.testCaseInfo = TestCaseInfo(id='3', name=self.__str__(), owner='Oliver') self.testReport = TestReport() LogUtil.create_logger_file(__name__) self.testCaseInfo.starttime = common.get_current_time() LogUtil.log('Open base url: %s' % self.base_url)
def agv_discharge_box(request): """ 卸船agv放箱 :param request: :return: """ print(request.POST) plan_id = request.POST.get('plan_id') plan_un_info = Plan_unloading.objects.get(plan_id=plan_id) container_info = Container.objects.filter(plan_id=plan_id) # agv agv_info = AGV.objects.get(agv_id=plan_un_info.agv_id) if plan_un_info.end_time: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) elif not plan_un_info.end_time_qc: data = { 'code': -1, 'msg': '上一工作环境未完成!', } return JsonResponse(data) else: # 记录结束时间 plan_un_info.end_time = get_current_time() plan_un_info.save() # 更改箱状态 for container in container_info: container.state = 1 container.save() data = { 'code': 0, 'msg': '操作成功,当前货箱卸船完成!', } # 更改vag状态 agv_info.state = 2 agv_info.save() # 箱状态列 container_info_list = Container.objects.filter(plan_id=plan_id) container_state_list = list() for container in container_info_list: container_state_list.append(container.state) container_state = list(set(container_state_list)) if len(container_state) > 1: pass else: if container_state[0] == 1: plan_un_info.state = 3 plan_un_info.save() return JsonResponse(data)
def discharge_box(request): """ 卸船岸桥放箱 :param request: :return: """ print(request.POST) plan_id = request.POST.get('plan_id') qc_id = request.POST.get('qc_id') qc_info = Quay_crane.objects.get(qc_id=qc_id) plan_un_info = Plan_unloading.objects.get(plan_id=plan_id) container_info = Container.objects.filter(plan_id=plan_id) # agv agv_free = AGV.objects.filter(situation=1, state=2) if plan_un_info.end_time_qc: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) elif not plan_un_info.state_time_land: data = { 'code': -1, 'msg': '上一工作环境未完成!', } return JsonResponse(data) else: if agv_free: # 获取空闲,且状态良好的agv 第一个 agv_info = agv_free[0] plan_un_info.agv_id = agv_info.agv_id plan_un_info.end_time_qc = get_current_time() plan_un_info.save() for container in container_info: container.agv_id = agv_info.agv_id container.save() data = { 'code': 0, 'msg': '操作成功!', } agv_info.state = 1 agv_info.save() qc_info.land_state = 2 qc_info.save() return JsonResponse(data) else: data = { 'code': -1, 'msg': '目前没有空闲的AGV!', } return JsonResponse(data)
def transfer(request): """ 卸船中转操作 :param request: :return: """ print(request.POST) plan_id = request.POST.get('plan_id') qc_id = request.POST.get('qc_id') qc_info = Quay_crane.objects.get(qc_id=qc_id) plan_un_info = Plan_unloading.objects.get(plan_id=plan_id) # middle_space 中转空间 middle_space = qc_info.middle_space container_count = Container.objects.filter(plan_id=plan_id).count() if plan_un_info.middle_time: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) elif not plan_un_info.state_time: data = { 'code': -1, 'msg': '上一工作环境未完成!', } return JsonResponse(data) else: if plan_un_info.state_time: if container_count <= int(middle_space): qc_info.sea_state = 2 qc_info.middle_space = int(middle_space) - container_count qc_info.save() plan_un_info.middle_time = get_current_time() plan_un_info.save() data = { 'code': 0, 'msg': '操作成功!', } return JsonResponse(data) else: data = { 'code': -1, 'msg': '中转平台空位不足!', } return JsonResponse(data) else: data = { 'code': -1, 'msg': '上一工作环境未完成!', } return JsonResponse(data)
def start_job(request): """ 装船开始作业 :param request: :return: """ print(request.POST) plan_id = request.POST.get('plan_id') qc_id = request.POST.get('qc_id') qc_info = Quay_crane.objects.get(qc_id=qc_id) plan_un_info = Plan_unloading.objects.get(plan_id=plan_id) container_info = Container.objects.filter(plan_id=plan_id) data_time = datetime.now().strftime('%Y%m%d') job_id = data_time + str(plan_id) print(job_id) # agv agv_free = AGV.objects.filter(situation=1, state=2) if plan_un_info.state_time: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) else: if agv_free: # 获取空闲,且状态良好的agv 第一个 agv_info = agv_free[0] plan_un_info.job_id = job_id plan_un_info.agv_id = agv_info.agv_id plan_un_info.state_time = get_current_time() plan_un_info.save() for container in container_info: container.agv_id = agv_info.agv_id container.save() data = { 'code': 0, 'msg': '操作成功!', } agv_info.state = 1 agv_info.save() qc_info.land_state = 2 qc_info.save() return JsonResponse(data) else: data = { 'code': -1, 'msg': '目前没有空闲的AGV!', } return JsonResponse(data)
def __init__(self): self.method = None self.caseId = None self.caseDescribe = None self.apiHost = None self.apiParams = None self.expect = None self.ispass = "******" self.reason = None if self.ispass == "pass": self.reason = "" self.time = get_current_time() self.fact = None self.databaseResult = None self.databaseExpect = None
def install_certificate(sid, uid, db: ConMysql): """ 安装证书 :param sid:session_id :return: """ cu = HebeSession(db) udid = "udid07A8-26B2-4749-AFF3-0435B6ED525" sql = """ INSERT INTO user_device_certificate (user_id,udid,issuer_cn,subject_cn,serial_number,not_before,client_ip,created_at) VALUES (%s,"%s","33ab9800f1378cb13ea4eeb6a4ce56af2987ec69", "D8DEBC4A-8EE7-4953-9259-556F87353D5C","13220895031545118235832", "2017-03-11 07:55:23","10.168.205.147","%s") """ % (uid, udid, get_current_time()) db.execute_sql(sql) cu.bind_sid_udid(sid=sid, udid=udid) info = cu.get_session_info(sid) if info.get("udid", "") == udid: log.info("证书安装成功") else: log.info("证书安装失败") sys.exit(-1)
def qc_job(request): """ 装船岸桥作业 :param request: :return: """ print(request.POST) box = request.POST.get('box') plan_id = request.POST.get('plan_id') qc_id = request.POST.get('qc_id') # 获取岸桥信息 qc_info = Quay_crane.objects.get(qc_id=qc_id) # 获取卸船计划信息 plan_un_info = Plan_unloading.objects.get(plan_id=plan_id) # 卸船计划编号对应的箱数量 container_count = Container.objects.filter(plan_id=plan_id).count() if box == '1': if plan_un_info.start_time_qc: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) else: if qc_info.land_state == 2: try: plan_un_info.state_time_land = get_current_time() plan_un_info.save() qc_info.land_state = 1 qc_info.save() except Exception as err: data = { 'code': -1, 'msg': '操作失败!', } return JsonResponse(data) data = { 'code': 0, 'msg': '操作成功!', } return JsonResponse(data) else: data = { 'code': -1, 'msg': '海侧吊具运行中,请稍后重试!', } return JsonResponse(data) elif box == '2': if plan_un_info.start_time_sea: data = { 'code': -1, 'msg': '当前环节以操作完成!', } return JsonResponse(data) else: if qc_info.sea_state == 2: if plan_un_info.middle_time: qc_info.sea_state = 1 qc_info.middle_space += container_count qc_info.save() plan_un_info.start_time_sea = get_current_time() plan_un_info.save() data = { 'code': 0, 'msg': '操作成功!', } return JsonResponse(data) else: data = { 'code': -1, 'msg': '上一工作环境未完成!', } return JsonResponse(data) else: data = { 'code': -1, 'msg': '陆侧吊具运行中,请稍后重试!', } return JsonResponse(data)