Example #1
0
def update_user(request):
    result = []
    db_obj = DataManager()
    result = db_obj.update_user(
        request.POST["name"],
        request.POST["workid"],
        request.POST["role"],
        request.POST["project"],
        request.POST["telephone"],
    )
    return HttpResponse(json.dumps(str(result), ensure_ascii=False))
Example #2
0
class TaskManager():
	'''
    任务管理:创建,更新,删除
	'''
	def __init__(self,type):
		# type : ui , api
		timestramp = datetime.now().strftime( '%Y-%m-%d_%H-%M-%S' )
		self.id = type+timestramp
		self.redis = redisConnector()
		self.db = DataManager()
	
	def create_task(self,version,product,caseid_list):
		pass
	
	def delete_task(self):
		pass
	
	def serach_task(self):
		pass

	def create_task(self,type,data):
		#创建任务,并存储到任务数据库
		version = data["version"]
		timestamp = time.strftime('%Y%m%d%H%M%S')
		taskid = type+'_'+timestamp+str(random.randrange(0, 101, 2))
		task = {
			"taskid":taskid,
			"type":type,
			"version":version,
			"data":data
		}
		
		self.db.create_ui_task(task)
		return True

	def add_cases_to_task(self,taskid,caselist):
		#添加caseid到任务表中
		for item in caselist:
			obj = {'taskid': taskid, 'caseid': item['caseid'],'status':'wait'}
			UiTaskCaseTable.objects.create(obj)
		
	def update_task(self,task_list):
		#任务完成更新任务状态
		pass
Example #3
0
def get_all_user(request):
    result = []
    tmpdata = {
        "workid": "1",
        "name": "王小虎",
        "role": "admin",
        "project": "core",
        "telephone": "12345"
    }
    db_obj = DataManager()
    re = db_obj.query_users()
    for i in re:
        result.append({
            "workid": i[2],
            "name": i[1],
            "role": i[3],
            "project": i[4],
            "telephone": i[5]
        })
    return HttpResponse(json.dumps(str(result), ensure_ascii=False))
Example #4
0
	def __init__(self,type):
		# type : ui , api
		timestramp = datetime.now().strftime( '%Y-%m-%d_%H-%M-%S' )
		self.id = type+timestramp
		self.redis = redisConnector()
		self.db = DataManager()
Example #5
0
 def _save_result(self, apiresult):
     db = DataManager()
     message = db.save_api_case(apiresult)
     if message != True:
         self.logger.error(message)