How to use is_function_test method in Slash

Best Python code snippet using slash

views.py

Source:views.py Github

copy

Full Screen

1#!usr/bin/env python2#coding: utf-83from django.http import HttpResponse, HttpResponseRedirect4from django.shortcuts import render_to_response,get_object_or_4045from django.core.context_processors import csrf6from django.template import RequestContext7from django.core.urlresolvers import reverse8from django.utils import simplejson9from django.core.paginator import Paginator, InvalidPage, EmptyPage10from django.contrib.auth.decorators import login_required11from django.db.models import Q1213from organization.models import Organization1415from neptune.settings import DEFAULT_FROM_EMAIL16from_email = DEFAULT_FROM_EMAIL17from django.template import loader18from utils.utils import send_mail1920from utils.constants import applyonline_status_dict21from utils import utils2223import time24import datetime2526from log.models import Log27from applyonline.models import ApplyOnline2829from utils.utils import isEquipmentStatus, isDate, isInt3031@login_required32def index(request):33 '''判断是否具备管理功能,如果具备则可以查看所有的申请单,如果不具备只能查看当前用户自己提交的申请单'''34 buttonlist = request.session["authority_list_button"]35 if 'applyonlinemanage' in buttonlist:36 applyonlines = ApplyOnline.objects.filter(flag=1).order_by('-id')37 else:38 applyonlines = ApplyOnline.objects.filter(flag=1, apply_user__iexact=request.user.username).order_by('-id')39 40 retdir = {}41 if 'applyid' in request.POST and request.POST['applyid']:42 applyid = request.POST['applyid']43 retdir['applyid'] = applyid44 applyonlines = applyonlines.filter(applyid__icontains = applyid)45 if 'status' in request.POST and request.POST['status']:46 status = request.POST['status']47 if status == 'all':48 retdir['status'] = status49 else:50 retdir['status'] = int(status)51 applyonlines = applyonlines.filter(status__iexact = int(status))52 if 'dateStart' in request.POST and request.POST['dateStart']:53 dateStart = request.POST['dateStart']54 retdir['dateStart'] = dateStart55 dateStart = time.strptime(dateStart, "%Y-%m-%d")56 dateStart = time.strftime("%Y-%m-%d %H:%M:%S", dateStart)57 dateStart = utils.secs2datestr(utils.datestr2secs(dateStart))58 applyonlines = applyonlines.filter(Q(apply_time__gte = dateStart))59 if 'dateEnd' in request.POST and request.POST['dateEnd']:60 dateEnd = request.POST['dateEnd']61 retdir['dateEnd'] = dateEnd62 dateEnd = time.strptime(dateEnd, "%Y-%m-%d")63 dateEnd = time.strftime("%Y-%m-%d %H:%M:%S", dateEnd)64 dateEnd = utils.secs2datestr(utils.datestr2secs(dateEnd) + 23*60*60 + 59*60 + 59)65 applyonlines = applyonlines.filter(Q(apply_time__lte = dateEnd))66 67 orderField = request.POST.get('orderField', None)68 orderDirection = request.POST.get('orderDirection', None)69 if orderField != None and orderField != '' and orderDirection != None and orderDirection != '':70 retdir['orderField'] = orderField71 retdir['orderDirection'] = orderDirection72 if orderDirection == 'asc':73 applyonlines = applyonlines.order_by(orderField)74 elif orderDirection == 'desc':75 applyonlines = applyonlines.order_by('-' + orderField)76 77 if 'numPerPage' in request.POST and request.POST['numPerPage']:78 numPerPage = request.POST['numPerPage']79 else:80 numPerPage = 1081 paginator = Paginator(applyonlines, numPerPage)82 page = request.POST.get('pageNum', 1)83 try:84 if int(page) > paginator.num_pages:85 page = str(paginator.num_pages)86 applyonlines = paginator.page(page)87 except (EmptyPage, InvalidPage):88 applyonlines = paginator.page(paginator.num_pages)89 tmpdir = {'applyonlines':applyonlines, 'currentPage':page, 'numPerPage':numPerPage, 'applyonline_status_dict':applyonline_status_dict}90 retdir.update(tmpdir)91 return render_to_response('applyonline/basepage.html', retdir, context_instance=RequestContext(request))92 939495@login_required96def detail(request, id):97 # 显示申请单的详情98 applyonline = ApplyOnline.objects.get(id = id)99 return render_to_response('applyonline/detail.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}, context_instance=RequestContext(request)) 100101102@login_required103def add(request):104 if request.POST:105# applyid = request.POST.get('applyid', None)106107 service_name = request.POST.get('service_name', None)108 service_domainname = request.POST.get('service_domainname', None)109 version = request.POST.get('version', None)110# apply_user = request.POST.get('apply_user', None)111 apply_user = request.user.username112 apply_time = request.POST.get('apply_time', None)113 priority = request.POST.get('priority', None)114 file_name = request.POST.get('file_name', None)115 file_url = request.POST.get('file_url', None)116 online_time = request.POST.get('online_time', None)117 develop_user = request.POST.get('develop_user', None)118 test_user = request.POST.get('test_user', None)119 operate_user = request.POST.get('operate_user', None)120 121 is_system_test = request.POST.get('is_system_test', None)122 is_function_test = request.POST.get('is_function_test', None)123 is_capability_test = request.POST.get('is_capability_test', None)124 is_pressure_test = request.POST.get('is_pressure_test', None)125 is_ui_test = request.POST.get('is_ui_test', None)126 is_special_test = request.POST.get('is_special_test', None)127 is_uat_test = request.POST.get('is_uat_test', None)128 is_stability_test = request.POST.get('is_stability_test', None)129 is_version_control = request.POST.get('is_version_control', None)130 is_train_complete = request.POST.get('is_train_complete', None)131 is_datatransfer_complete = request.POST.get('is_datatransfer_complete', None)132 is_document_complete = request.POST.get('is_document_complete', None)133 is_environment_complete = request.POST.get('is_environment_complete', None)134 is_backup_plan = request.POST.get('is_backup_plan', None)135 is_paramconf_complete = request.POST.get('is_paramconf_complete', None)136 is_can_online = request.POST.get('is_can_online', None)137 is_check_url = request.POST.get('is_check_url', None)138 139 check_url = request.POST.get('check_url', None)140 141 deploy_step = request.POST.get('deploy_step', None)142 backup_method = request.POST.get('backup_method', None)143 update_check = request.POST.get('update_check', None)144 145 146 '''自动生成申请单号'''147 prefix = 'OP-SR-'148 time_list = apply_time.split('-')149 timestr = ''.join(time_list)150 applyonline_count = ApplyOnline.objects.filter(apply_time=datetime.date(int(time_list[0]), int(time_list[1]), int(time_list[2]))).count()151 applyid = prefix + timestr + '-' + str(applyonline_count+1)152 153 '''验证重复申请单号'''154 applyids = ApplyOnline.objects.filter(applyid__iexact=applyid)155 if applyids:156 return HttpResponse(simplejson.dumps({"statusCode":302, "navTabId":request.POST.get('navTabId', 'applyonlineindex'), "callbackType":request.POST.get('callbackType',None), "message":u'申请单号已经存在不能添加'}), mimetype='application/json')157 applyonline = ApplyOnline(applyid=applyid, service_name=service_name, service_domainname=service_domainname, 158 version=version, apply_user=apply_user, apply_time=apply_time, file_name=file_name, 159 file_url=file_url, online_time=online_time, develop_user=develop_user, test_user=test_user,160 operate_user=operate_user, check_url=check_url, deploy_step=deploy_step, backup_method=backup_method, 161 update_check=update_check, status=0, flag=1)162 163 applyonline.save()164 165 applyonline.priority = int(priority)166 applyonline.is_system_test = int(is_system_test)167 applyonline.is_function_test = int(is_function_test)168 applyonline.is_capability_test = int(is_capability_test)169 applyonline.is_pressure_test = int(is_pressure_test)170 applyonline.is_ui_test = int(is_ui_test)171 applyonline.is_special_test = int(is_special_test)172 applyonline.is_uat_test = int(is_uat_test)173 applyonline.is_stability_test = int(is_stability_test)174 applyonline.is_version_control = int(is_version_control)175 applyonline.is_train_complete = int(is_train_complete)176 applyonline.is_datatransfer_complete = int(is_datatransfer_complete)177 applyonline.is_document_complete = int(is_document_complete)178 applyonline.is_environment_complete = int(is_environment_complete)179 applyonline.is_backup_plan = int(is_backup_plan)180 applyonline.is_paramconf_complete = int(is_paramconf_complete)181 applyonline.is_can_online = int(is_can_online)182 applyonline.is_check_url = int(is_check_url)183 184 applyonline.save()185 186 187 '''申请人添加完申请单后向运维相关人员发送邮件提示'''188 subject = u'服务上线申请'189 to_mail_list = []190 if operate_user != None and operate_user != '':191 usernamelist = operate_user.split(',')192 for username in usernamelist:193 username += '@autonavi.com'194 to_mail_list.append(username)195 # 定义邮件内容196 email = u"您好,现在已向您发送了服务器上线申请,以下是基本信息,详细信息请登录CMDB系统查询:"197 body = loader.render_to_string('applyonline/mail_operate.html', {'email':email, 'applyonline':applyonline})198 send_mail(subject, body, from_email, to_mail_list, html="text/html")199 200 201 Log(username=request.user.username, content="execute add applyonline:" + applyonline.applyid + " success!", level=1).save()202 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId', 'equipmentindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'添加成功'}), mimetype='application/json')203 else:204 # 弹出新建窗口205 return render_to_response('applyonline/add.html', {'applyonline_status_dict':applyonline_status_dict})206207@login_required208def edit(request, id):209 applyonline = get_object_or_404(ApplyOnline, pk=int(id))210 if request.POST:211 applyonline_desc = request.POST.get('applyonline_desc', None)212 applyonline.applyonline_desc = applyonline_desc213 applyonline.save()214 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'编辑成功'}), mimetype='application/json')215 return render_to_response('applyonline/edit.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}) 216217@login_required218def deploy_success(request, id):219 applyonline = get_object_or_404(ApplyOnline, pk=int(id))220 if request.POST:221 applyonline_desc = request.POST.get('applyonline_desc', None)222 if applyonline.applyonline_desc != None:223 applyonline.applyonline_desc += '\n' + applyonline_desc224 else:225 applyonline.applyonline_desc = applyonline_desc226 applyonline.status = 1227 applyonline.save()228 229 230 '''运维人员部署成功后向相关人员发送邮件提示,提醒相关人员进行验证'''231 subject = u'服务上线验证'232 to_mail_list = []233 if applyonline.apply_user != None and applyonline.apply_user != '':234 usernamelist = applyonline.apply_user.split(',')235 for username in usernamelist:236 username += '@autonavi.com'237 to_mail_list.append(username)238 # 定义邮件内容239 email = u"您好,服务部署成功,请进行相应的验证:"240 body = loader.render_to_string('applyonline/mail_deploy_success.html', {'email':email, 'applyonline':applyonline})241 send_mail(subject, body, from_email, to_mail_list, html="text/html")242 243 244 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'操作成功'}), mimetype='application/json')245 return render_to_response('applyonline/deploy_success.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}) 246247@login_required248def deploy_failure(request, id):249 applyonline = get_object_or_404(ApplyOnline, pk=int(id))250 if request.POST:251 applyonline_desc = request.POST.get('applyonline_desc', None)252 if applyonline.applyonline_desc != None:253 applyonline.applyonline_desc += '\n' + applyonline_desc254 else:255 applyonline.applyonline_desc = applyonline_desc256 applyonline.status = 3257 applyonline.save()258 259 '''运维人员部署失败后向申请人发送邮件提示'''260 subject = u'服务上线失败'261 to_mail_list = []262 if applyonline.apply_user != None and applyonline.apply_user != '':263 usernamelist = applyonline.apply_user.split(',')264 for username in usernamelist:265 username += '@autonavi.com'266 to_mail_list.append(username)267 # 定义邮件内容268 email = u"您好,服务器上线失败,请检查申请单并重新填写一份申请单:"269 body = loader.render_to_string('applyonline/mail_deploy_failure.html', {'email':email, 'applyonline':applyonline})270 send_mail(subject, body, from_email, to_mail_list, html="text/html")271 272 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'操作成功'}), mimetype='application/json')273 return render_to_response('applyonline/deploy_failure.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}) 274275@login_required276def validate_success(request, id):277 applyonline = get_object_or_404(ApplyOnline, pk=int(id))278 if request.POST:279 applyonline_desc = request.POST.get('applyonline_desc', None)280 if applyonline.applyonline_desc != None:281 applyonline.applyonline_desc += '\n' + applyonline_desc282 else:283 applyonline.applyonline_desc = applyonline_desc284 applyonline.status = 2285 applyonline.save()286 287 288 '''申请人验证成功后向运维人员发送邮件提示'''289 subject = u'服务验证成功'290 to_mail_list = []291 if applyonline.apply_user != None and applyonline.apply_user != '':292 usernamelist = applyonline.apply_user.split(',')293 for username in usernamelist:294 username += '@autonavi.com'295 to_mail_list.append(username)296 # 定义邮件内容297 email = u"您好,服务验证成功,谢谢您的大力支持!"298 body = loader.render_to_string('applyonline/mail_validate_success.html', {'email':email, 'applyonline':applyonline})299 send_mail(subject, body, from_email, to_mail_list, html="text/html")300 301 302 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'操作成功'}), mimetype='application/json')303 return render_to_response('applyonline/validate_success.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}) 304305@login_required306def validate_failure(request, id):307 applyonline = get_object_or_404(ApplyOnline, pk=int(id))308 if request.POST:309 applyonline_desc = request.POST.get('applyonline_desc', None)310 if applyonline.applyonline_desc != None:311 applyonline.applyonline_desc += '\n' + applyonline_desc312 else:313 applyonline.applyonline_desc = applyonline_desc314 applyonline.status = 3315 applyonline.save()316 317 '''申请人验证失败后向运维人员发送邮件提示'''318 subject = u'服务验证失败'319 to_mail_list = []320 if applyonline.apply_user != None and applyonline.apply_user != '':321 usernamelist = applyonline.apply_user.split(',')322 for username in usernamelist:323 username += '@autonavi.com'324 to_mail_list.append(username)325 # 定义邮件内容326 email = u"您好,服务验证失败,我会重新发一份申请单,请您重新部署:"327 body = loader.render_to_string('applyonline/mail_validate_failure.html', {'email':email, 'applyonline':applyonline})328 send_mail(subject, body, from_email, to_mail_list, html="text/html")329 330 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType','closeCurrent'), "message":u'操作成功'}), mimetype='application/json')331 return render_to_response('applyonline/validate_failure.html', {'applyonline':applyonline, 'applyonline_status_dict':applyonline_status_dict}) 332333@login_required334def delete(request,id):335 applyonline = ApplyOnline.objects.get(id=id)336 Log(username=request.user.username, content="execute delete applyonline:" + applyonline.applyid + " success!", level=1).save()337 applyonline.flag = 0338 applyonline.save()339 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType',''), "message":u'删除成功'}), mimetype='application/json')340341@login_required342def selecteddelete(request):343 ids = request.POST.get('ids', None)344 if ids:345 applyonlines = ApplyOnline.objects.extra(where=['id IN ('+ ids +')'])346 applyonlines.update(flag=0)347 for applyonline in applyonlines:348 Log(username=request.user.username, content="execute selecteddelete applyonline:" + applyonline.applyid + " success!", level=1).save()349 applyonline.save()350 return HttpResponse(simplejson.dumps({"statusCode":200, "navTabId":request.POST.get('navTabId','applyonlineindex'), "callbackType":request.POST.get('callbackType',''), "message":u'选中项删除成功'}), mimetype='application/json')351352353354355 ...

Full Screen

Full Screen

types_tests.bzl

Source:types_tests.bzl Github

copy

Full Screen

...124 asserts.false(env, types.is_dict(_a_function))125 asserts.false(env, types.is_dict(depset()))126 return unittest.end(env)127is_dict_test = unittest.make(_is_dict_test)128def _is_function_test(ctx):129 """Unit tests for types.is_function."""130 env = unittest.begin(ctx)131 asserts.true(env, types.is_function(_a_function))132 asserts.false(env, types.is_function({}))133 asserts.false(env, types.is_function(1))134 asserts.false(env, types.is_function("s"))135 asserts.false(env, types.is_function(()))136 asserts.false(env, types.is_function(True))137 asserts.false(env, types.is_function([]))138 asserts.false(env, types.is_function([1]))139 asserts.false(env, types.is_function(None))140 asserts.false(env, types.is_function(depset()))141 return unittest.end(env)142is_function_test = unittest.make(_is_function_test)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful