How to use test_node_order method in avocado

Best Python code snippet using avocado_python

testlink_xml_generate.py

Source:testlink_xml_generate.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3'''4from spec(.xls) to gererate testlink xml file5'''6import sys7import xlrd8reload(sys)9sys.setdefaultencoding("utf-8")10from xml.dom import minidom11import random12#### global value13EXTERNALID = 10014INTERNALID = 765432115SUITE_NODE_ORDER = 016CASE_NODE_OREDER = 017DATA_MODEL = ''18ENTER = r'<br/>'19SPACE = r'&nbsp;'20P = r'<p>'21Pend = r'</p>'22steplist_r = [23 'Use GetParameterValues method get CPE default value',24 'Use SetParameterValues method set CPE value',25 'Use GetParameterValues method get CPE value should not change.',26 'Use SetParameterAttribute method change CPE node attibution.0:Notification-Non,1:Passive-Notification,2:Active-Notification',27 'Use GetParameterAttribute method get CPE node attibution.',28 ]29resultlist_r = [30 'CPE response default',31 'CPE response',32 'CPE response',33 'CPE response will not response any confirm information',34 'CPE response should same with attribute setting.'35 ]36steplist_w = [37 'Use GetParameterValues method get CPE default value',38 'Use SetParameterValues method set CPE value',39 'Use GetParameterValues method get CPE value should same with setting.',40 'Use SetParameterValues method set CPE invalid value',41 'Use GetParameterValues method get CPE value should not change.',42 'Use SetParameterAttribute method change CPE node attibution.0:Non-Notification,1:Passive-Notification,2:Active-Notification',43 'Use GetParameterAttribute method get CPE node attibution.'44 ]45resultlist_w = [46 'CPE response default',47 'CPE response',48 'CPE response',49 'CPE response',50 'CPE response',51 'CPE response will not response any confirm information',52 'CPE response should same with attribute setting.'53 ]54get_objective="Verify the data model node by TR069 RPC method SetParameterValues and GetParameterValues"55set_objective="Verify the data model node by TR069 RPC method only support GetParameterValues"56## generate random 'string'57seed = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'58## generate random 'hexBinary'59seed_16 = '1234567890ABCDEFabcdef'60def rand(num,seed):61 list=[]62 for i in range(num):63 r = random.choice(seed)64 list.append(r)65 string=''.join(list)66 return string67## split the min, max number of int[], unsignedInt[]68def Int_Min_Max(datatype):69 # if datatype == 'int[-1:15][16:31]':70 # valuelist = {'valid':[-1,0,15],'invalid':[max_+1,'abc']}71 # else:72 minnum = datatype.split('[')[1].split(']')[0].split(':')[0]73 maxnum = datatype.split('[')[1].split(']')[0].split(':')[1]74 if minnum != '':75 min_ = int(minnum)76 if maxnum != '':77 max_ = int(maxnum)78 if minnum == '':79 if datatype.startswith('int['):80 min_ = -500081 if max_ > 0:82 valuelist = {'valid':[min_,0,max_],'invalid':[max_+1,'abc']}83 else:84 valuelist = {'valid':[min_,max_],'invalid':[max_+1,'abc']}85 elif datatype.startswith('unsignedInt['):86 min_ = 087 valuelist = {'valid':[min_,max_],'invalid':[max_+1,'abc']}88 elif maxnum == '':89 max_ = 500090 if min_ < 0:91 valuelist = {'valid':[min_,0,max_],'invalid':[min_-1,'abc']}92 else:93 valuelist = {'valid':[min_,max_],'invalid':[min_-1,'abc']}94 else:95 if min_ < 0 and max_ > 0:96 valuelist = {'valid':[min_,0,max_],'invalid':[min_-1,max_+1,'abc']}97 else:98 valuelist = {'valid':[min_,max_],'invalid':[min_-1,max_+1,'abc']}99 return valuelist100##101def String_Min_Max(datatype):102 if ':' in datatype: ## string(a:b)103 minlen = datatype.split('(')[1].split(')')[0].split(':')[0]104 maxlen = datatype.split('(')[1].split(')')[0].split(':')[1]105 min_ = int(minlen)106 if min_ == 0:107 min_ = 1108 max_ = int(maxlen)109 valuelist = {'valid':[rand(min_,seed),rand(max_,seed)],'invalid':[rand(min_-1,seed),rand(max_+1,seed)]}110 else: ## string(b)111 maxlen = datatype.split('(')[1].split(')')[0]112 max_ = int(maxlen)113 valuelist = {'valid':[rand(1,seed),rand(max_,seed)],'invalid':[rand(max_+1,seed)]}114 return valuelist115#################valuelist116def GetValueList(datatype):117 if datatype == 'boolean':118 valuelist = {'valid':['true','false'],'invalid':[2,'abc']}119 elif datatype == 'dataTime':120 valuelist = {'valid':['2011-08-22T00:55:54'],'invalid':['Thu Aug 22 19:24:28 2011']}121 elif datatype == 'int':122 valuelist = {'valid':[-32768,0,32767],'invalid':[123.123,'abc']}123 elif datatype.startswith('int['):124 valuelist = Int_Min_Max(datatype)125 elif datatype == 'unsignedInt':126 valuelist = {'valid':[0,65535],'invalid':[-1,'abc']}127 elif datatype.startswith('unsignedInt['):128 valuelist = Int_Min_Max(datatype)129 elif datatype == 'unsignedLong':130 valuelist = {'valid':[0,4294967295],'invalid':[-1,'abc']}131 elif datatype == 'long':132 valuelist = {'valid':[-2147483648,0,2147483647],'invalid':[-2147483649,2147483648,'abc']}133 elif datatype == 'string':134 valuelist = {'valid':['abcdefg','1234567890'],'invalid':[]}135 elif datatype.startswith('string('):136 valuelist = String_Min_Max(datatype)137 elif datatype.startswith('hexBinary('):138 min_ = 0139 max_ = 0140 if datatype == 'hexBinary(5:5)(13:13)':141 valuelist ={'valid':[rand(10, seed_16),rand(26, seed_16)],'invalid':[rand(8, seed_16),rand(12,seed_16),rand(24,seed_16),rand(28, seed_16)]}142 elif ':' in datatype: ## hexBinary(a:b)143 minlen = datatype.split('(')[1].split(')')[0].split(':')[0]144 maxlen = datatype.split('(')[1].split(')')[0].split(':')[1]145 if minlen != '':146 min_ = int(minlen)147 if maxlen != '':148 max_ = int(maxlen)149 valuelist = {'valid':[rand(min_*2,seed_16),rand(max_*2,seed_16)],'invalid':[rand((min_-1)*2,seed_16),rand((max_+1)*2,seed_16),rand(max_*2-1,seed_16)]}150 else: ## hexBinary(b)151 maxlen = datatype.split('(')[1].split(')')[0]152 max_ = int(maxlen)153 valuelist = {'valid':[rand(2,seed_16),rand(max_*2,seed_16)],'invalid':[rand(1,seed_16),rand((max_+1)*2,seed_16),rand(max_*2-1,seed_16)]}154 elif datatype.startswith('base64('): ## =string155 valuelist = String_Min_Max(datatype)156 else:157 valuelist = {'valid':['abcdefg','1234567890'],'invalid':[]} ## string158 return valuelist159#**************************************************160#####161def Summary(testcase,datatype,defaultvalue,validvalue,invalidvalue,access,samplevalue):162 case_summ_content = P + '<strong style="font-family: '+"'Trebuchet MS'"+', Verdana, Arial, sans-serif;">Objective:</strong>' + Pend163 case_summ_content = case_summ_content + P + 'Verify the data model node by TR069 RPC method'+SPACE+'SetParameterValues and'+SPACE+'GetParameterValues'+SPACE + Pend164 case_summ_content = case_summ_content + '<p style="font-family: '+"'Trebuchet MS'"+', Verdana, Arial, sans-serif; background-color: rgb(238, 238, 238);">' + '<strong>Pre-condition:</strong>'+ Pend165 case_summ_content = case_summ_content + P +SPACE+ 'DUT in default mode' + Pend166 case_summ_content = case_summ_content + P + '<strong style="font-family: '+"'Trebuchet MS'"+', Verdana, Arial, sans-serif;">'+'Spec Parameters:'+'</strong>'+'<a id='+'"fck_paste_padding"'+'>'+r'</a>' + Pend167 case_summ_content = case_summ_content + r'<table width="598" height="143" cellspacing="1" cellpadding="1" border="1">'168 if access == 'r':169 case_summ_content = case_summ_content + r'<tbody>'+r'<tr>'+r'<td>'+' Data Type'+r'</td>'+r'<td>'+SPACE+datatype+r'</td>'+r'</tr>'+ r'<tr>'+r'<td>'+' Default Value' + r'</td>' + r'<td>'+SPACE+defaultvalue+r'</td>' + r'</tr>'+r'<tr>'+r'<td>'+' Sample Value'+r'</td>'+r'<td>'+SPACE+samplevalue+r'</td>'+r'</tbody>'170 elif access == 'w':171 case_summ_content = case_summ_content + r'<tbody>'+r'<tr>'+r'<td>'+' Data Type'+r'</td>'+r'<td>'+SPACE+datatype+r'</td>'+r'</tr>'+ r'<tr>'+r'<td>'+' Default Value' + r'</td>' + r'<td>'+SPACE+defaultvalue+r'</td>' + r'</tr>'+r'<tr>'+r'<td>'+' Valid Value'+r'</td>'+r'<td>'+SPACE+validvalue+r'</td>'+r'<tr>'+r'<td>'+' Invalid Value'+r'</td>'+r'<td>'+SPACE+invalidvalue+r'</td>'+r'</tr>'+r'</tbody>'172 case_summ_content = case_summ_content + r'</table>'173 case_summ_content = case_summ_content + P + r'<a id="fck_paste_padding">'+SPACE+r'</a>'+ Pend174 return case_summ_content175#####176def Step(type,default,steplist,case_name,access):177 step_content=P178 if access == 'r':179 step1_content='1.'+SPACE*2+steplist[0]+ENTER180 step2_content='2.'+SPACE*2+steplist[1]+ENTER181 step2_content+=SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER182 step2_content+=SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+r'/Name'+r'&gt;'+ENTER183 step2_content=step2_content+SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'+ type+r'&quot;'+r'&gt;'+'1234567890'+r'&lt;'+'/Value'+r'&gt;'+ENTER184 step2_content=step2_content+SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER185 step3_content='3.'+SPACE*2+steplist[2]+ENTER186 step4_content='4.'+SPACE*2+steplist[3]+ENTER187 step4_content+=SPACE*3+r'&lt;'+'SetParameterAttributesStruct'+r'&gt;'+ENTER188 step4_content+=SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER189 step4_content+=SPACE*9+r'&lt;'+'NotificationChange'+'&gt;'+'1'+r'&lt;'+'/NotificationChange'+r'&gt;'+ENTER190 step4_content+=SPACE*9+r'&lt;'+'Notification'+r'&gt;'+'0/1/2'+r'&lt;'+'/Notification'+r'&gt;'+ENTER191 step4_content+=SPACE*9+r'&lt;'+'AccessListChange'+r'&gt;'+'0'+r'&lt;'+'/AccessListChange'+r'&gt;'+ENTER192 step4_content+=SPACE*9+r'&lt;'+'AccessList SOAP-ENC:arrayType='+r'&quot;'+'xsd:string[0]'+r'&quot;'+'/'+r'&gt;'+ENTER193 step4_content+=SPACE*7+r'&lt;'+'/SetParameterAttributesStruct'+r'&gt;'+ENTER194 step5_content='5.'+SPACE*2+steplist[4]+ENTER195 step5_content+=SPACE*3+r'&lt;'+'cwmp:GetParameterAttributes xmlns:cwmp='+r'&quot;'+'urn:dslforum-org:cwmp-1-0'+r'&quot;'+r'&gt;'+ENTER196 step5_content+=SPACE*9+r'&lt;'+'ParameterNames SOAP-ENC:arrayType='+r'&quot;'+'xsd:string[1]'+r'&quot;'+r'&gt;'+ENTER197 step5_content+=SPACE*11+r'&lt;'+'string'+r'&gt;'+case_name+r'&lt;'+'/string'+r'&gt;'+ENTER198 step5_content+=SPACE*9+r'&lt;'+'/ParameterNames'+r'&gt;'+ENTER199 step5_content+=SPACE*7+r'&lt;'+'/cwmp:GetParameterAttributes'+r'&gt;'200 step_content+=step1_content+step2_content+step3_content+step4_content+step5_content+Pend201 elif access == 'w':202 step1_content = '1.'+SPACE*2+steplist[0]+ENTER203 step2_content = '2.'+SPACE*2+steplist[1]+ENTER+SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER+SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+r'/Name'+r'&gt;'+ENTER204 step2_content = step2_content+SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'205 step2_content = step2_content+type+r'&quot;'+r'&gt;'+'Valid Value'+r'&lt;'+'/Value'+r'&gt;'+ENTER206 step2_content = step2_content+SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER207 step3_content = '3.'+SPACE*2+steplist[2]+ENTER208 step4_content = '4.'+SPACE*2+steplist[3]+ENTER+SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER+SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+r'/Name'+r'&gt;'+ENTER209 step4_content = step4_content+SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'210 step4_content = step4_content+type+r'&quot;'+r'&gt;'+'Invalid Value'+r'&lt;'+'/Value'+r'&gt;'+ENTER211 step4_content = step4_content+SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER212 step5_content = '5.'+SPACE*2+steplist[4]+ENTER213 step6_content = '6.'+SPACE*2+steplist[5]+ENTER214 step6_content = step6_content+SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER215 step6_content = step6_content+SPACE*9+r'&lt;'+'NotificationChange'+r'&gt;'+'1'+r'&lt;'+'/NotificationChange'+r'&gt;'+ENTER216 step6_content = step6_content+SPACE*9+r'&lt;'+'Notification'+r'&gt;'+'0/1/2'+r'&lt;'+'/Notification'+r'&gt;'+ENTER217 step6_content = step6_content+SPACE*9+r'&lt;'+'AccessListChange'+r'&gt;'+'0'+r'&lt;'+'/AccessListChange'+r'&gt;'+ENTER218 step6_content = step6_content+SPACE*9+r'&lt;'+'AccessList SOAP-ENC:arrayType='+r'&quot;'+'xsd:string[0]'+r'&quot;'+r'/&gt;'+ENTER219 step6_content = step6_content+SPACE*7+r'&lt;'+'/SetParameterAttributesStruct'+r'/&gt;'+ENTER220 step7_content = '7.'+SPACE*2+steplist[6]+ENTER221 step7_content = step7_content+SPACE*3+r'&lt;'+'cwmp:GetParameterAttributes xmlns:cwmp='+r'&quot;'+'urn:dslforum-org:cwmp-1-0'+r'&quot;'+r'&gt;'+ENTER222 step7_content = step7_content+SPACE*9+r'&lt;'+'ParameterNames SOAP-ENC:arrayType='+r'&quot;'+'xsd:string[1]'+r'&quot;'+r'&gt;'+ENTER223 step7_content = step7_content+SPACE*11+r'&lt;'+'string'+r'&gt;'+case_name+r'&lt;'+'/string'+r'&gt;'+ENTER224 step7_content = step7_content+SPACE*9+r'&lt;'+'/ParameterNames'+r'&gt;'+ENTER225 step7_content = step7_content+SPACE*7+r'&lt;'+'/cwmp:GetParameterAttributes'+r'&gt;'226 step_content += step1_content+step2_content+step3_content+step4_content+step5_content+step6_content+step7_content+Pend227 return step_content228######229def ExpectedResult(resultlist,case_name,default,type,access):230 result_content = P231 if access == 'r':232 result1_content='1.'+resultlist[0]+ENTER233 result1_content+=SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER234 result1_content+=SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER235 result1_content+=SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'+type+r'&quot;'+r'&gt;'+default+r'&lt;'+'/Value'+r'&gt;'+ENTER236 result1_content+=SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER237 result2_content='2.'+resultlist[1]+ENTER238 result2_content+=SPACE*3+r'&lt;'+'SOAP-ENV:Fault'+'&gt;'+ENTER239 result2_content+=SPACE*9+r'&lt;'+'faultcode'+r'&gt;'+'Client'+r'&lt;'+'/faultcode'+r'&gt;'+ENTER240 result2_content+=SPACE*9+r'&lt;'+'faultstring'+r'&gt;'+'CWMP fault'+r'&lt;'+'/faultstring'+r'&gt;'+ENTER241 result2_content+=SPACE*9+r'&lt;'+'detail'+r'&gt;'+ENTER242 result2_content+=SPACE*11+r'&lt;'+'cwmp:Fault'+r'&gt;'+ENTER243 result2_content+=SPACE*13+r'&lt;'+'FaultCode'+r'&gt;'+'9003'+r'&lt;'+'/FaultCode'+r'&gt;'+ENTER244 result2_content+=SPACE*13+r'&lt;'+'FaultString'+r'&gt;'+'Invalid arguments'+r'&lt;'+'/FaultString'+r'&gt;'+ENTER245 result2_content+=SPACE*13+r'&lt;'+'SetParameterValuesFault'+r'&gt;'+ENTER246 result2_content+=SPACE*15+r'&lt;'+'ParameterName'+r'&gt;'+case_name+r'&lt;'+'/ParameterName'+r'&gt;'+ENTER247 result2_content+=SPACE*15+r'&lt;'+'FaultCode'r'&gt;'+'9008'+r'&lt;'+'/FaultCode'+r'&gt;'+ENTER248 result2_content+=SPACE*15+r'&lt;'+'FaultString'+r'&gt;'+'Attempt to set a non-writable parameter'+r'&lt;'+'/FaultString'+r'&gt;'+ENTER249 result2_content+=SPACE*13+r'&lt;'+'/cwmp:Fault'+r'&gt;'+ENTER250 result2_content+=SPACE*9+r'&lt;'+'/detail'+r'&gt;'+ENTER251 result2_content+=SPACE*7+r'&lt;'+'/SOAP-ENV:Fault'+r'&gt;'+ENTER252 result3_content='3.'+resultlist[2]+ENTER253 result3_content+=SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER254 result3_content+=SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER255 result3_content+=SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+r'xsd:'+type+r'&quot;'+r'&gt;'+default+r'&lt;'+'/Value'+r'&gt;'+ENTER256 result3_content+=SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER257 result4_content='4.'+resultlist[3]+ENTER258 result4_content+=SPACE*3+r'&lt;'+'cwmp:SetParameterAttributesResponse/'+r'&gt;'+ENTER259 result5_content='5.'+resultlist[4]+ENTER260 result5_content+=SPACE*3+r'&lt;'+'cwmp:GetParameterAttributesResponse'+r'&gt;'+ENTER261 result5_content+=SPACE*5+r'&lt;'+'ParameterList SOAP-ENC:arrayType='+r'&quot;'+'ParameterAttributeStruct[1]'+r'&quot;'+r'&gt;'+ENTER262 result5_content+=SPACE*7+r'&lt;'+'ParameterAttributeStruct'+r'&gt;'+ENTER263 result5_content+=SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER264 result5_content+=SPACE*9+r'&lt;'+'Notification'+r'&gt;'+'0/1/2'+r'&lt;'+'/Notification'+r'&gt;'+ENTER265 result5_content+=SPACE*9+r'&lt;'+'AccessList xsi:type='+r'&quot;'+'tns:AccessList'+r'&quot;'+r'/&gt;'+ENTER266 result5_content+=SPACE*7+r'&lt;'+'/ParameterAttributeStruct'+r'&gt;'+ENTER267 result5_content+=SPACE*5+r'&lt;'+'/ParameterList'+r'&gt;'+ENTER268 result5_content+=SPACE*3+r'&lt;'+'/cwmp:GetParameterAttributesResponse'+r'&gt;'269 result_content+=result1_content+result2_content+result3_content+result4_content+result5_content+Pend270 elif access == 'w':271 result1_content = '1.'+resultlist[0]+ENTER272 result1_content += SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER273 result1_content += SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER274 result1_content += SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'275 result1_content = result1_content+type+r'&quot;'+r'&gt;'+default+r'&lt;'+'/Value'+r'&gt;'+ENTER276 result1_content += SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER277 result2_content = '2.'+resultlist[1]+ENTER278 result2_content += SPACE*3+r'&lt;'+'cwmp:SetParameterValuesResponse'+r'&gt;'+ENTER279 result2_content += SPACE*9+r'&lt;'+'Status xsi:type='+r'&quot;'+'xsd:int'+r'&quot;'+r'&gt;'+'0'+r'&lt;'+'/Status'+r'&gt;'+ENTER280 result2_content += SPACE*6+r'&lt;'+'/cwmp:SetParameterValuesResponse'+r'&gt;'+ENTER281 result3_content = '3.'+resultlist[2]+ENTER282 result3_content += SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER283 result3_content += SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER284 result3_content += SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+r'xsd:'+type+r'&quot;'+r'&gt;'+'Valid Value'+r'&lt;'+'/Value'+r'&gt;'+ENTER285 result3_content += SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER286 result4_content = '4.'+resultlist[3]+ENTER287 result4_content += SPACE*3+r'&lt;'+'SOAP-ENV:Fault'+r'&gt;'+ENTER288 result4_content += SPACE*9+r'&lt;'+'faultcode'+r'&gt;'+'Client'+r'&lt;'+'/faultcode'+r'&gt;'+ENTER289 result4_content += SPACE*9+r'&lt;'+'faultstring'+r'&gt;'+'CWMP fault'+r'&lt;'+'/faultstring'+r'&gt;'+ENTER290 result4_content += SPACE*9+r'&lt;'+'detail'r'&gt;'+ENTER291 result4_content += SPACE*11+r'&lt;'+'cwmp:Fault'+r'&gt;'+ENTER292 result4_content += SPACE*13+r'&lt;'+'FaultCode'+r'&gt;'+'9003'+r'&lt;'+'/FaultCode'+r'&gt;'+ENTER293 result4_content += SPACE*13+r'&lt;'+'FaultString'+r'&gt;'+'Invalid arguments'+r'&lt;'+'/FaultString'+r'&gt;'+ENTER294 result4_content += SPACE*13+r'&lt;'+'SetParameterValuesFault'+r'&gt;'+ENTER295 result4_content += SPACE*15+r'&lt;'+'ParameterName'+r'&gt;'+case_name+r'&lt;'+'/ParameterName'+r'&gt;'+ENTER296 result4_content += SPACE*15+r'&lt;'+'FaultCode'+r'&gt;'+'9007'+r'&lt;'+'/FaultCode'+r'&gt;'+ENTER297 result4_content += SPACE*15+r'&lt;'+'FaultString'+r'&gt;'+'Invalid Parameter value'+r'&lt;'+'/FaultString'+r'&gt;'+ENTER298 result4_content += SPACE*13+r'&lt;'+'/SetParameterValuesFault'+r'&gt;'+ENTER299 result4_content += SPACE*11+r'&lt;'+'/cwmp:Fault'+r'&gt;'+ENTER300 result4_content += SPACE*9+r'&lt;'+'/detail'+r'&gt;'+ENTER301 result4_content += SPACE*7+r'&lt;'+'/SOAP-ENV:Fault'+r'&gt;'+ENTER302 result5_content = '5.'+resultlist[4]+ENTER303 result5_content += SPACE*3+r'&lt;'+'ParameterValueStruct'+r'&gt;'+ENTER304 result5_content += SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER305 result5_content += SPACE*9+r'&lt;'+'Value xsi:type='+r'&quot;'+'xsd:'+type+r'&quot;'+r'&gt;'+'Vaild Value [-1]'+r'&lt;'+'/Value'+r'&gt;'+ENTER306 result5_content += SPACE*7+r'&lt;'+'/ParameterValueStruct'+r'&gt;'+ENTER307 result6_content = '6.'+resultlist[5]+ENTER308 result6_content += SPACE*3+r'&lt;'+'cwmp:SetParameterAttributesResponse/'+r'&gt;'+ENTER309 result7_content = '7.'+resultlist[6]+ENTER310 result7_content += SPACE*3+r'&lt;'+'cwmp:GetParameterAttributesResponse'+r'&gt;'+ENTER311 result7_content += SPACE*5+r'&lt;'+'ParameterList SOAP-ENC:arrayType='+r'&quot;'+'ParameterAttributeStruct[1]'+r'&quot;'+r'&gt;'+ENTER312 result7_content += SPACE*7+r'&lt;'+'ParameterAttributeStruct'+r'&gt;'+ENTER313 result7_content += SPACE*9+r'&lt;'+'Name'+r'&gt;'+case_name+r'&lt;'+'/Name'+r'&gt;'+ENTER314 result7_content += SPACE*9+r'&lt;'+'Notification'+r'&gt;'+'0/1/2'+r'&lt;'+'/Notification'+r'&gt;'+ENTER315 result7_content += SPACE*9+r'&lt;'+'AccessList xsi:type='+r'&quot;'+'tns:AccessList'+r'&quot;'+r'/&gt;'+ENTER316 result7_content += SPACE*7+r'&lt;'+'/ParameterAttributeStruct'+'&gt;'+ENTER317 result7_content += SPACE*5+r'&lt;'+'/ParameterList'+r'&gt;'+ENTER318 result7_content += SPACE*3+r'&lt;'+'/cwmp:GetParameterAttributesResponse'+r'&gt;'319 result_content += result1_content+result2_content+result3_content+result4_content+result5_content+result6_content+result7_content+Pend320 return result_content321#####322###############################################323def CreateOneCase(doc,list,Attribute):324 global EXTERNALID325 global INTERNALID326 global SUITE_NODE_ORDER327 global CASE_NODE_OREDER328 global DATA_MODEL329 support = list[0] # Support Y/N330 nodename = list[1]331 datatype = list[2]332 valuelist = GetValueList(datatype)333 if 'string' in datatype:334 type='string'335 elif 'dateTime' in datatype:336 type='datetime'337 elif 'boolean' in datatype:338 type='boolean'339 elif 'unsigned' in datatype:340 type='unsignedInt'341 elif 'int' in datatype or 'long' in datatype:342 type='int'343 elif 'signed' in datatype:344 type='signedint'345 else:346 type='string' # other datatype347 access = list[3]348 # description = list[4]349 defaultvalue = list[5]350 if defaultvalue == '':351 defaultvalue = '-'352 default = defaultvalue353 if default == '-':354 default = ''355 samplevalue = list[6] ## Read-Only parameter356 if samplevalue == '':357 samplevalue = '-' ## Read-Write parameter358 validvalue = list[6]359 if validvalue == '':360 validvalue = valuelist['valid']361 for i in range(0,len(validvalue)):362 validvalue[i] = str(validvalue[i])363 validvalue = "; ".join(validvalue)364 invalidvalue = valuelist['invalid']365 for i in range(0,len(invalidvalue)):366 invalidvalue[i] = str(invalidvalue[i])367 invalidvalue = "; ".join(invalidvalue)368 if invalidvalue == '':369 invalidvalue = '-'370 #***********************************************#371 if support == 'N':372 return 0373 elif support == 'Y':374 if datatype == 'object':375 DATA_MODEL = nodename.strip()376 return 0377 else:378 if access == 'r':379 if Attribute == 'w':380 return 0381 elif Attribute == 'r':382 steplist = steplist_r383 resultlist = resultlist_r384 elif access == 'w':385 if Attribute == 'r':386 return 0387 elif Attribute == 'w':388 steplist = steplist_w389 resultlist = resultlist_w390 case_name = DATA_MODEL + nodename.strip()391 testcase = doc.createElement('testcase')392 testcase.setAttribute('name',case_name)393 INTERNALID +=1394 testcase.setAttribute('internalid',str(INTERNALID))395 CASE_NODE_OREDER +=1396 test_node_order = doc.createElement('node_order')397 test_node_order.appendChild(doc.createCDATASection(str(CASE_NODE_OREDER)))398 testcase.appendChild(test_node_order)399 EXTERNALID +=1400 test_extid = doc.createElement('externalid')401 test_extid.appendChild( doc.createCDATASection(str(EXTERNALID)))402 testcase.appendChild(test_extid)403 test_summ = doc.createElement('summary')404 case_summ_content = Summary(testcase,datatype,defaultvalue,validvalue,invalidvalue,access,samplevalue)405 test_summ.appendChild(doc.createCDATASection(case_summ_content))406 testcase.appendChild(test_summ)407 test_step = doc.createElement('steps')408 step_content = Step(type,defaultvalue,steplist,case_name,access)409 test_step.appendChild(doc.createCDATASection(step_content))410 testcase.appendChild(test_step)411 test_expect = doc.createElement('expectedresults')412 result_content = ExpectedResult(resultlist,case_name,default,type,access)413 test_expect.appendChild(doc.createCDATASection(result_content))414 testcase.appendChild(test_expect)415 return testcase416#############################################################417def main():418 #*********running parameter********#419 helpnote = 'The script requires 6 parameters:\n'420 helpnote += ' para1: ExcelFile e.g. TR069_DataModles_Definition.xls\n'421 helpnote += ' para2: SheetFile e.g. tr181\n'422 helpnote += ' para3: Attribute e.g. r or w\n'423 helpnote += ' -- node is writable or non-writable\n'424 helpnote += ' para4: XmlFile e.g. tr181-r-1.xml\n'425 helpnote += ' -- Attention: the size of XmlFile must less than 8MB\n'426 helpnote += ' -- When generating big file, we should set "StartRow","EndRow" to different values to divide into several parts\n'427 helpnote += ' para5: StartRow e.g. 1\n'428 helpnote += ' -- start row of excel for current generation\n'429 helpnote += ' para6: EndRow e.g. 1000\n'430 helpnote += ' -- end row of excel for current generation\n'431 helpnote += ' -- e.g. part1: 1 1000, part2: 1000 2000, part3: 2000 3314\n'432 helpnote += ' para7: SuitName e.g. TR181-R-Part1\n'433 if sys.argv[1] == '-h':434 print helpnote435 elif len(sys.argv) != 8: ## + sys.argv[0]436 print '<ERROR> Wrong Parametr Number!\r\n' + helpnote437 else:438 ExcelFile = sys.argv[1]439 SheetFile = sys.argv[2]440 Attribute = sys.argv[3]441 XmlFile = sys.argv[4]442 StartRow = int(sys.argv[5])443 EndRow = int(sys.argv[6])444 SuitName = sys.argv[7]445 doc = minidom.Document()446 testsuite = doc.createElement('testsuite')447 testsuite.setAttribute('name',SuitName)448 doc.appendChild(testsuite)449 node_order = doc.createElement('node_order')450 node_order.appendChild(doc.createCDATASection('1'))451 details = doc.createElement('details')452 details.appendChild(doc.createCDATASection(''))453 testsuite.appendChild(node_order)454 testsuite.appendChild(details)455 ## read excel456 book = xlrd.open_workbook(ExcelFile)457 sheet = book.sheet_by_name(SheetFile)458 nrows = sheet.nrows ## 获得行数459 ncols = sheet.ncols ## 获得列数460 # List_table = []461 for i in range(StartRow,EndRow):462 List = [] ## list combined with a line data463 for j in range(0,ncols):464 cellvalue = sheet.cell(i,j).value465 List.append(cellvalue)466 # print List[0]467 # List_table.append(List)468 testcase = CreateOneCase(doc,List,Attribute)469 if testcase != 0:470 testsuite.appendChild(testcase)471 fileID = open(XmlFile,'w')472 fileID.write(doc.toprettyxml())473 fileID.flush()474 fileID.close()475###############################################476if __name__ == "__main__":...

Full Screen

Full Screen

test_core.py

Source:test_core.py Github

copy

Full Screen

...197 cnt2 += 1198 print(cnt1, cnt2)199 assert cnt2 == 10200 assert cnt1 <= 33, cnt1201 def test_node_order(self):202 a = jt.nn.Sequential()203 for i in range(10):204 a.append(jt.nn.Linear(10,10, bias=False))205 sgd = jt.optim.SGD(a.parameters(), 0.1)206 jt.sync_all()207 with jt.log_capture_scope(log_silent=1,208 log_vprefix="exe=100") as logs:209 x = jt.rand(3,10)210 y = a(x)211 sgd.step(y*y)212 jt.sync_all()213 orders = []214 for l in logs:215 msg = l["msg"]...

Full Screen

Full Screen

test_graph.py

Source:test_graph.py Github

copy

Full Screen

...33 a = Node.view(original, original.id)34 self.assertEqual(a.is_mutable(), original.is_mutable())35 self.assertEqual(set(a.labels()), {"Person"})36 self.assertEqual(dict(a), {"name": "Alice"})37 def test_node_order(self):38 a = Node("Person", name="Alice")39 self.assertEqual(graph_order(a), 1)40 def test_node_size(self):41 a = Node("Person", name="Alice")42 self.assertEqual(graph_size(a), 0)43 def test_node_labels(self):44 a = Node("Person", "Employee", name="Alice")45 self.assertEqual(set(a.labels()), {"Person", "Employee"})46 def test_node_properties(self):47 a = Node("Person", name="Alice", age=33)48 self.assertEqual(set(a.keys()), {"name", "age"})49 self.assertEqual(set(a.values()), {"Alice", 33})50 self.assertEqual(set(a.items()), {("name", "Alice"), ("age", 33)})51 def test_node_property_assignment(self):...

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 avocado 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