How to use test_next method in autotest

Best Python code snippet using autotest_python

auto_test.js

Source:auto_test.js Github

copy

Full Screen

...1098 g_mcloud_agent.play({sn:g_selectedDevice.name,protocol:proto,token:"p0"},obj.ref_obj,1099 function(msg,ref)1100 {1101 msg.result?system_pop_confirm_box({alert:true,index:1,str:"play error: "+msg.result}):chl_video_create({type:"play",url:msg.url, params:"", inner_window_info:ref.inner_window_info});1102 test_next();1103 });1104 }1105 }1106 }1107 1108 function get_sd_info()1109 {1110 g_mcloud_agent.sd_get({sn:g_selectedDevice.name},null,function(msg,ref){1111 if(msg.result==""){1112 msg.capacity>0?add_test_li("sd_info",1):add_test_li("sd_info",2);1113 }else{system_pop_confirm_box({alert:true,index:1,str:"get_sd_info error: "+msg.result});}1114 test_next();1115 });1116 }1117 function set_mode(obj)1118 {1119 var set_mode_div=$("set_mode_div");1120 if(obj.flag)1121 {1122 var content_div=$("set_mode_content_div"),1123 triangle_span=$("set_mode_triangle_span"),1124 left_num=$("set_mode_button").offsetLeft+$("set_mode_button").offsetWidth/2-11;1125 content_div.style.left=left_num-23+"px";1126 content_div.style.bottom=-5+"px";1127 triangle_span.style.left=left_num+"px";1128 set_mode_div.style.display="block";1129 g_set_mode_flag=0;1130 }1131 else1132 {1133 // set_mode_div.style.display="none";1134 g_set_mode_flag=1;1135 }1136 if(obj.type&&obj.type!="set_mode")1137 {1138 g_mcloud_agent.cam_get({sn:g_selectedDevice.name},null,function(msg,ref){1139 if(msg.result!=""){1140 system_pop_confirm_box({alert:true,index:1,str:"get_mode error: "+msg.result});1141 test_next();1142 }1143 else{1144 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:msg.brightness,contrast:msg.contrast,color_saturation:msg.color_saturation,sharpness:msg.sharpness,day_night:obj.type,flip:msg.flip,flicker_freq:msg.flicker_freq},null,function(msg,ref){1145 if(msg.result!=""){system_pop_confirm_box({alert:true,index:1,str:"set_mode error: "+msg.result});}1146 test_next();1147 });1148 }1149 });1150 set_mode_div.style.display="none";1151 g_set_mode_flag=1;1152 }1153 }1154 function set_wifi_connect()1155 {1156 test_next();1157 if(g_wifi_connect_button.textContent=="连接中..")1158 {1159 g_wifi_connect_button.textContent="WiFi连接";1160 g_wifi_connect_flag=-1;1161 }1162 if(g_wifi_connect_flag==-1) return;1163 g_wifi_connect_flag=1;1164 if(g_wifi_ssid_input.value&&g_wifi_pass_input.value)1165 {1166 var now_net_info=[],wifi_connect_times=0;1167 g_wifi_connect_button.textContent="连接中..";1168 $("wifi_connect_span").textContent=" :进行中..";1169 $("wifi_connect_span").style.color="#ffffff";1170 set_storage_data({str:"wifi_info", data:{ssid:g_wifi_ssid_input.value,pass:g_wifi_pass_input.value}});1171 now_net_info["ifs"] = {token:"ra0", enabled:1};1172 now_net_info["dns"]= {conf:{enalbed: 0,mode: "dhcp",static_dns:{0: "0.0.0.0"}}};1173 now_net_info.ifs["phy"] = {conf:{mode:"wificlient",mtu: 0}};1174 now_net_info.ifs["ipv4"] = {conf:{debug_ip: "",enabled: 1,mode: "dhcp",static_ip: ""}};1175 now_net_info.ifs["wifi_client"] ={conf:{enabled:1,ssid:g_wifi_ssid_input.value,key:g_wifi_pass_input.value,usr:g_wifi_ssid_input.value}};1176 g_mcloud_agent.net_set({sn:g_selectedDevice.name,networks:now_net_info.ifs,dns:now_net_info.dns},null,function(msg,ref){1177 //test_next();1178 if(msg.result==""){1179 get_network_info_request();1180 }1181 else1182 {1183 add_test_li("wifi_connect",2);1184 g_wifi_connect_button.textContent="WiFi连接";1185 system_pop_confirm_box({alert:true,index:1,str:"set_wifi_connect error: "+msg.result});1186 }1187 });1188 function get_network_info_request()1189 {1190 var get_network_timeout_id;1191 g_mcloud_agent.net_get({sn:g_selectedDevice.name},null,function(msg,ref){1192 if(msg.result==""){1193 var now_ifs = msg.networks[1];1194 wifi_connect_times++;1195 if((now_ifs.ipv4.info.status == "ok"||now_ifs.ipv4.info.stat == "ok")&& wifi_connect_times>3)1196 {1197 add_test_li("wifi_connect",1);1198 $("dev_site_wifi").href="http://"+now_ifs.ipv4.info.ip.addr;1199 $("dev_site_wifi").textContent="WiFi:"+now_ifs.ipv4.info.ip.addr;1200 g_wifi_connect_button.textContent="WiFi连接";1201 if(g_test_array_names[g_test_array_names.length-1]=="wifi_connect")1202 {1203 g_auto_test_flag=0;1204 g_test_button.textContent="开始测试";1205 }1206 }1207 else if(wifi_connect_times<9)1208 {1209 if(g_wifi_connect_flag)1210 {1211 get_network_timeout_id=setTimeout(function(){1212 get_network_info_request();1213 },4000);1214 }1215 else1216 {1217 $("wifi_connect_span").textContent=" :取消";1218 $("wifi_connect_span").style.color="#ffffff";1219 g_wifi_connect_button.textContent="WiFi连接";1220 clearTimeout(get_network_timeout_id);1221 }1222 }1223 else1224 {1225 clearTimeout(get_network_timeout_id);1226 add_test_li("wifi_connect",2);1227 g_wifi_connect_button.textContent="WiFi连接";1228 if(g_test_array_names[g_test_array_names.length-1]=="wifi_connect")1229 {1230 g_auto_test_flag=0;1231 g_test_button.textContent="开始测试";1232 }1233 return;1234 }1235 }1236 else1237 {1238 system_pop_confirm_box({alert:true,index:1,str:"get_wifi_list error: "+msg.result});1239 g_wifi_connect_button.textContent="WiFi连接";1240 }1241 });1242 }1243 }1244 else1245 {1246 system_pop_confirm_box({alert:true,index:1,str:"wifi ssid或密码为空"});1247 // stop_test();1248 $("wifi_connect_span").textContent=" :取消";1249 $("wifi_connect_span").style.color="#ffffff";1250 g_wifi_connect_button.textContent="WiFi连接";1251 }1252 }1253 function test_info_(){1254 add_test_li("test_info",0);1255 g_mcloud_agent.dev_info_get({sn:g_selectedDevice.name},null,function(msg,ref){1256 if(msg.result==""){1257 add_test_li("test_info",1);1258 test_next("info");1259 }else{1260 add_test_li("test_info",msg.result);1261 test_next("info");1262 }1263 });1264 }1265 function test_nick_(){1266 add_test_li("test_nick",0);1267 g_mcloud_agent.nick_set({sn:g_selectedDevice.name,name:"test_name"},null,function(msg,ref){1268 if(msg.result==""){1269 g_mcloud_agent.nick_set({sn:g_selectedDevice.name,name:g_selectedDevice.name},null,function(msg,ref){1270 if(msg.result==""){1271 add_test_li("test_nick",1);1272 test_next("nick");1273 }else{1274 add_test_li("test_nick",msg.result);1275 test_next("nick");1276 }1277 });1278 }else{1279 add_test_li("test_nick",msg.result);1280 test_next("nick");1281 }1282 });1283 }1284 function test_osd_(){1285 add_test_li("test_osd",0);1286 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:1,week_enable:1,date_format:"YYYY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1287 if(msg.result==""){1288 add_test_li("test_osd",1);1289 }else{1290 add_test_li("test_osd",msg.result);1291 }1292 });1293 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:1,week_enable:1,date_format:"YYZY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1294 if(msg.result==""){1295 add_test_li("test_osd",1);1296 test_next("osd");1297 }else{1298 add_test_li("test_osd",msg.result);1299 test_next("osd");1300 }1301 });1302 }1303 function test_sd_(){1304 add_test_li("test_sd",0);1305 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:1},null,function(msg,ref){1306 if(msg.result==""){1307 add_test_li("test_sd",1);1308 test_next("sd");1309 }else{1310 add_test_li("test_sd",msg.result);1311 test_next("sd");1312 }1313 });1314 }1315 function test_alert_(){1316 add_test_li("test_alert",0);1317 g_mcloud_agent.alarm_trigger_set({sn:g_selectedDevice.name,io_input:'Open',io_output:'Open',sensitivity:'112',night_sensitivity:'-12'},null,function(msg,ref){1318 if(msg.result==""){1319 add_test_li("test_alert",1);1320 test_next("alert");1321 }else{1322 add_test_li("test_alert",msg.result);1323 test_next("alert");1324 }1325 });1326 }1327 function test_connect_(){1328 add_test_li("test_connect",0);1329 var actions = {token:'motion_alert',enable:0,name:"motion_alert",srcs:[{devs:"motion"}],io_out_enable:0,snapshot_enable:1,record_enbale:1,snapshot_interval:0,pre_record_time:"3",io_alert_time:"3"};1330 g_mcloud_agent.alarm_action_set({sn:g_selectedDevice.name,enable:0,actions:actions},null,function(msg,ref){1331 if(msg.result==""){1332 add_test_li("test_connect",1);1333 test_next("connect");1334 }else{1335 add_test_li("test_connect",msg.result);1336 test_next("connect");1337 }1338 });1339 }1340 function test_date_(){1341 add_test_li("test_date",0);1342 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'manually',auto_sync:0,ntp_addr:"210.72.145.44",timezone:"UTC+09:00",hour:'5',min:'5',sec:'5',year:'2005',mon:'5',day:'5'},null,function(msg,ref){1343 if(msg.result==""){1344 add_test_li("test_date",1);1345 }else{1346 add_test_li("test_date",msg.result);1347 }1348 });1349 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'manually',auto_sync:0,ntp_addr:"210.72.145.44",timezone:"UTC+09:00",hour:'5',min:'75',sec:'5',year:'2005',mon:'5',day:'5'},null,function(msg,ref){1350 if(msg.result==""){1351 add_test_li("test_date",1);1352 test_next("date");1353 }else{1354 add_test_li("test_date",msg.result);1355 test_next("date");1356 }1357 });1358 }1359 function test_audio_(){1360 add_test_li("test_audio",0);1361 g_mcloud_agent.audio_set({sn:g_selectedDevice.name,speaker_level:33,mic_level:33},null,function(msg,ref){1362 if(msg.result==""){1363 add_test_li("test_audio",1);1364 test_next("audio");1365 }else{1366 add_test_li("test_audio",msg.result);1367 test_next("audio");1368 }1369 });1370 }1371 function test_net_(){1372 add_test_li("test_net",0);1373 g_mcloud_agent.net_set({sn:g_selectedDevice.name,networks:{enabled:1,ipv4:{conf:{debug_ip:'',enabled:1,mode:'static',static_ip:{addr:'192.168.1.111',gw:'192.168.1.1',mask:'255.255.255.0'}}},wifi_client:{conf:{enabled:1,key:'11223344',ssid:'anlory',user:'anlory'}},token: 'ra0'},dns:{conf:{enalbed:0,mode:'static',static_dns:['8.8.8.8','4.2.2.1']}}},null,function(msg,ref){1374 if(msg.result==""){1375 add_test_li("test_net",1);1376 test_next("net");1377 }else{1378 add_test_li("test_net",msg.result);1379 test_next("net");1380 }1381 });1382 }1383 function test_mode_(){1384 add_test_li("test_mode",0);1385 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'-61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1386 if(msg.result==""){1387 add_test_li("test_mode",1);1388 test_next("mode");1389 }else{1390 add_test_li("test_mode",msg.result);1391 test_next("mode");1392 }1393 });1394 }1395 function test_system_(){1396 add_test_li("test_system",0);1397 add_test_li("test_system",1);1398 test_next("system");1399 }1400 function test_pic_(){1401 add_test_li("test_pic",0);1402 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,token:"p0"},null,function(msg,ref){1403 if(msg.result==""){1404 add_test_li("test_pic",1);1405 test_next("pic");1406 }else{1407 add_test_li("test_pic",msg.result);1408 test_next("pic");1409 }1410 });1411 }1412 function test_next(text){1413 var i = 0;1414 if(g_auto_test_flag==1){1415 for(i =0;i<g_test_select.length;i++)1416 {1417 if(g_test_select[i]==text && i< (g_test_select.length-1))1418 {1419 test(g_test_select[i+1]);1420 break;1421 }1422 }1423 }1424 }1425 function test_plan_(){1426 add_test_li("test_plan",0);//wday 取值后7位二进制1427 g_mcloud_agent.record_set({sn:g_selectedDevice.name,enable:1,full_time:0,times:[{wday:127,start:1200,end:5400}]},null,function(msg,ref){1428 if(msg.result==""){1429 add_test_li("test_plan",1);1430 test_next("plan");1431 }else{1432 add_test_li("test_plan",msg.result);1433 test_next("plan");1434 }1435 });1436 }1437 function test_direct_(){1438 add_test_li("test_direct",0);1439 add_test_li("test_direct",1);1440 test_next("direct");1441 }1442 function test_dev_start_(){1443 add_test_li("test_dev_start",0);1444 add_test_li("test_dev_start",1);1445 test_next("dev_start");1446 }1447 function test_date_syn_(){1448 add_test_li("test_date_syn",0);1449 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'manually',auto_sync:0,ntp_addr:"210.72.145.33",timezone:"UTC+08:00",hour:'5',min:'5',sec:'5',year:'2005',mon:'5',day:'5'},null,function(msg,ref){1450 if(msg.result==""){1451 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'NTP',auto_sync:1,ntp_addr:"210.72.145.44",timezone:"UTC+08:00",hour:'6',min:'6',sec:'5',year:'2006',mon:'6',day:'6'},null,function(msg,ref){1452 if(msg.result==""){1453 add_test_li("test_date_syn",1);1454 test_next("date_syn");1455 }else{1456 add_test_li("test_date_syn",msg.result);1457 test_next("date_syn");1458 }1459 });1460 }else{1461 add_test_li("test_date_syn",msg.result);1462 test_next("date_syn");1463 }1464 });1465 }1466 function test_sys_timezone_(){1467 add_test_li("test_sys_timezone",0);1468 var hour;1469 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'NTP',auto_sync:1,ntp_addr:"210.72.145.44",timezone:"UTC+08:00",hour:'6',min:'6',sec:'5',year:'2006',mon:'6',day:'6'},null,function(msg,ref){1470 if(msg.result==""){1471 g_mcloud_agent.time_get({sn:g_selectedDevice.name},null,function(msg,ref){1472 if(msg.result==""){1473 hour=msg.hour;1474 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'NTP',auto_sync:1,ntp_addr:"210.72.145.44",timezone:"UTC+09:00",hour:'6',min:'6',sec:'5',year:'2006',mon:'6',day:'6'},null,function(msg,ref){1475 if(msg.result==""){1476 g_mcloud_agent.time_get({sn:g_selectedDevice.name},null,function(msg,ref){1477 if(msg.result==""){1478 if(msg.hour==(hour+1))1479 add_test_li("test_sys_timezone",1);1480 else1481 add_test_li("test_sys_timezone","set timezone failed");1482 test_next("sys_timezone");1483 }else{1484 add_test_li("test_sys_timezone",msg.result);1485 test_next("sys_timezone");1486 }1487 });1488 }else{1489 add_test_li("test_sys_timezone",msg.result);1490 test_next("sys_timezone");1491 }1492 });1493 }else{1494 add_test_li("test_sys_timezone",msg.result);1495 test_next("sys_timezone");1496 }1497 });1498 }else{1499 add_test_li("test_sys_timezone",msg.result);1500 test_next("sys_timezone");1501 }1502 });1503 }1504 function test_wifi_get_(){1505 add_test_li("test_wifi_get",0);1506 g_mcloud_agent.net_get({sn:g_selectedDevice.name},null,function(msg,ref){1507 if(msg.result==""){1508 if(msg.networks[1].wifi_client.ap_list[0].ssid ==""){1509 add_test_li("test_wifi_get","wifi_list get error!");1510 test_next("wifi_get");1511 }else{1512 add_test_li("test_wifi_get",1);1513 test_next("wifi_get");1514 }1515 }else{1516 add_test_li("test_wifi_get",msg.result);1517 test_next("wifi_get");1518 }1519 });1520 }1521 function test_wifi_connect_(){1522 if(g_wifi_ssid_input.value&&g_wifi_pass_input.value) {1523 var now_net_info = [], wifi_connect_times = 0;1524 add_test_li("test_wifi_connect", 0);1525 set_storage_data({str: "wifi_info", data: {ssid: g_wifi_ssid_input.value, pass: g_wifi_pass_input.value}});1526 now_net_info["ifs"] = {token: "ra0", enabled: 1};1527 now_net_info["dns"] = {conf: {enalbed: 0, mode: "dhcp", static_dns: {0: "0.0.0.0"}}};1528 now_net_info.ifs["phy"] = {conf: {mode: "wificlient", mtu: 0}};1529 now_net_info.ifs["ipv4"] = {conf: {debug_ip: "", enabled: 1, mode: "dhcp", static_ip: ""}};1530 now_net_info.ifs["wifi_client"] = {conf: {enabled: 1, ssid: g_wifi_ssid_input.value, key: g_wifi_pass_input.value, usr: g_wifi_ssid_input.value}};1531 g_mcloud_agent.net_set({sn: g_selectedDevice.name, networks: now_net_info.ifs, dns: now_net_info.dns}, null, function (msg, ref) {1532 //test_next();1533 if (msg.result == "") {1534 setTimeout(function(){1535 g_mcloud_agent.net_get({sn:g_selectedDevice.name},null,function(msg,ref){1536 if(msg.result==""){1537 if(msg.networks[1].ipv4.info.ip.gw =="0.0.0.0"){1538 add_test_li("test_wifi_connect","连接失败");1539 test_next("wifi_connect");1540 }else{1541 add_test_li("test_wifi_connect",1);1542 test_next("wifi_connect");1543 }1544 }else{1545 add_test_li("test_wifi_connect",msg.result);1546 test_next("wifi_connect");1547 }1548 });1549 },20000);1550 }1551 else {1552 add_test_li("test_wifi_connect", msg.result);1553 test_next("wifi_connect");1554 }1555 });1556 }else{1557 add_test_li("test_wifi_connect", "please input wifi ssid and password!");1558 test_next("wifi_connect");1559 }1560 }1561 function test_wifi_ip_(){1562 add_test_li("test_wifi_ip",0);1563 add_test_li("test_wifi_ip",1);1564 test_next("wifi_ip");1565 }1566 function test_wifi_set_(){1567 add_test_li("test_wifi_set",0);1568 add_test_li("test_wifi_set",1);1569 test_next("wifi_set");1570 }1571 function test_isp_set_(){1572 add_test_li("test_isp_set",0);1573 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1574 if(msg.result==""){1575 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'71',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1576 if(msg.result==""){1577 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'61',color_saturation:'21',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1578 if(msg.result==""){1579 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'61',color_saturation:'71',sharpness:'9',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1580 if(msg.result==""){1581 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'25',contrast:'61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1582 if(msg.result==""){1583 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'61',color_saturation:'62',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1584 if(msg.result==""){1585 add_test_li("test_isp_set",1);1586 test_next("isp_set");1587 }else{1588 add_test_li("test_isp_set",msg.result);1589 test_next("isp_set");1590 }1591 });1592 }else{1593 add_test_li("test_isp_set",msg.result);1594 test_next("isp_set");1595 }1596 });1597 }else{1598 add_test_li("test_isp_set",msg.result);1599 test_next("isp_set");1600 }1601 });1602 }else{1603 add_test_li("test_isp_set",msg.result);1604 test_next("isp_set");1605 }1606 });1607 }else{1608 add_test_li("test_isp_set",msg.result);1609 test_next("isp_set");1610 }1611 });1612 }else{1613 add_test_li("test_isp_set",msg.result);1614 test_next("isp_set");1615 }1616 });1617 }1618 function test_osd_set_(){1619 add_test_li("test_osd_set",0);1620 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:0,week_enable:0,date_format:"YYYY-MM-DD",time_12h:0,time_enable:0},null,function(msg,ref){1621 if(msg.result==""){1622 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:0,date_enable:1,week_enable:0,date_format:"YYYY-MM-DD",time_12h:0,time_enable:0},null,function(msg,ref){1623 if(msg.result==""){1624 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:0,date_enable:0,week_enable:1,date_format:"YYYY-MM-DD",time_12h:0,time_enable:0},null,function(msg,ref){1625 if(msg.result==""){1626 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:0,date_enable:0,week_enable:0,date_format:"YYYY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1627 if(msg.result==""){1628 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:1,week_enable:0,date_format:"YYYY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1629 if(msg.result==""){1630 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:1,week_enable:1,date_format:"YYYY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1631 if(msg.result==""){1632 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:0,date_enable:0,week_enable:0,date_format:"YYYY-MM-DD",time_12h:0,time_enable:0},null,function(msg,ref){1633 if(msg.result==""){1634 add_test_li("test_osd_set",1);1635 test_next("osd_set");1636 }else{1637 add_test_li("test_osd_set",msg.result);1638 test_next("osd_set");1639 }1640 });1641 }else{1642 add_test_li("test_osd_set",msg.result);1643 test_next("osd_set");1644 }1645 });1646 }else{1647 add_test_li("test_osd_set",msg.result);1648 test_next("osd_set");1649 }1650 });1651 }else{1652 add_test_li("test_osd_set",msg.result);1653 test_next("osd_set");1654 }1655 });1656 }else{1657 add_test_li("test_osd_set",msg.result);1658 test_next("osd_set");1659 }1660 });1661 }else{1662 add_test_li("test_osd_set",msg.result);1663 test_next("osd_set");1664 }1665 });1666 }else{1667 add_test_li("test_osd_set",msg.result);1668 test_next("osd_set");1669 }1670 });1671 }1672 function test_dev_flip_(){1673 add_test_li("test_dev_flip",0);1674 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'-61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:1,flicker_freq:0},null,function(msg,ref){1675 if(msg.result==""){1676 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'-61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1677 if(msg.result==""){1678 add_test_li("test_dev_flip",1);1679 test_next("dev_flip");1680 }else{1681 add_test_li("test_dev_flip",msg.result);1682 test_next("dev_flip");1683 }1684 });1685 }else{1686 add_test_li("test_dev_flip",msg.result);1687 test_next("dev_flip");1688 }1689 });1690 }1691 function test_sd_format_(){1692 add_test_li("test_sd_format",0);1693 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"mount"},null,function(msg,ref){1694 if(msg.result==""){1695 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"format"},null,function(msg,ref){1696 if(msg.result==""){1697 setTimeout(function(){1698 g_mcloud_agent.sd_get({sn:g_selectedDevice.name},null,function(msg,ref){1699 if(msg.result==""){1700 if(msg.usage==0){1701 add_test_li("test_sd_format",1);1702 test_next("sd_format");1703 }else{1704 add_test_li("test_sd_format","format sd failed");1705 test_next("sd_format");1706 }1707 }else{1708 add_test_li("test_sd_format",msg.result);1709 test_next("sd_format");1710 }1711 });1712 },10000);1713 }else{1714 add_test_li("test_sd_format",msg.result);1715 test_next("sd_format");1716 }1717 });1718 }else{1719 add_test_li("test_sd_format",msg.result);1720 test_next("sd_format");1721 }1722 });1723 }1724 function test_sd_show_(){1725 add_test_li("test_sd_show",0);1726 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"mount"},null,function(msg,ref){1727 if(msg.result==""){1728 setTimeout(function(){var a=3;},5000);1729 g_mcloud_agent.sd_get({sn:g_selectedDevice.name},null,function(msg,ref){1730 if(msg.result==""){1731 if((msg.capacity=="")){1732 add_test_li("test_sd_show", " sd_show failed");1733 test_next("sd_show");1734 }else{1735 add_test_li("test_sd_show",1);1736 test_next("sd_show");1737 }1738 }else{1739 add_test_li("test_sd_show",msg.result);1740 test_next("sd_show");1741 }1742 });1743 }else{1744 add_test_li("test_sd_show",msg.result);1745 test_next("sd_show");1746 }1747 });1748 }1749 function test_sd_load_(){1750 add_test_li("test_sd_load",0);1751 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"umount"},null,function(msg,ref){1752 if(msg.result==""){1753 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"mount"},null,function(msg,ref){1754 if(msg.result==""){1755 setTimeout(function(){1756 g_mcloud_agent.sd_get({sn:g_selectedDevice.name},null,function(msg,ref){1757 if(msg.result==""){1758 if((msg.capacity=="")){1759 add_test_li("test_sd_load", " sd_load failed");1760 test_next("sd_load");1761 }else{1762 add_test_li("test_sd_load",1);1763 test_next("sd_load");1764 }1765 }else{1766 add_test_li("test_sd_load",msg.result);1767 test_next("sd_load");1768 }1769 });1770 },10000);1771 }else{1772 add_test_li("test_sd_load",msg.result);1773 test_next("sd_load");1774 }1775 });1776 }else{1777 add_test_li("test_sd_load",msg.result);1778 test_next("sd_load");1779 }1780 });1781 }1782 function test_sd_unload_(){1783 add_test_li("test_sd_unload",0);1784 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"mount"},null,function(msg,ref){1785 if(msg.result==""){1786 g_mcloud_agent.sd_set({sn:g_selectedDevice.name,no_conf:0,enable:1,ctrl_type:"umount"},null,function(msg,ref){1787 if(msg.result==""){1788 add_test_li("test_sd_unload",1);1789 test_next("sd_unload");1790 }else{1791 add_test_li("test_sd_unload",msg.result);1792 test_next("sd_unload");1793 }1794 });1795 }else{1796 add_test_li("test_sd_unload",msg.result);1797 test_next("sd_unload");1798 }1799 });1800 }1801 function test_admin_(){1802 add_test_li("test_admin",0);1803 var pass=g_default_pass_input.value;1804 g_mcloud_agent.sign_in({srv : g_selectedDevice.ip,user : g_selectedDevice.name,password : g_default_pass_input.value}, null,1805 function(msg, ref) {1806 if(msg.result==""){1807 g_mcloud_agent.dev_passwd_set({sn:g_selectedDevice.name,is_guest:0,old_pass:g_default_pass_input.value,new_pass:"123456"},null,function(msg,ref){1808 if(msg.result==""){1809 add_test_li("test_admin",1);1810 }else{1811 add_test_li("test_admin",msg.result);1812 }1813 });1814 }else{1815 add_test_li("test_admin",msg.result);1816 }1817 });1818 }1819 function test_guest_(){1820 add_test_li("test_guest",0);1821 var pass=g_default_pass_input.value;1822 g_mcloud_agent.dev_passwd_set({sn:g_selectedDevice.name,is_guest:1,old_pass:g_default_pass_input.value,new_pass:"111111"},null,function(msg,ref){1823 if(msg.result==""){1824 g_mcloud_agent.sign_in({srv : g_selectedDevice.ip,user : g_selectedDevice.name,password :"111111"}, null,1825 function(msg, ref) {1826 if(msg.result==""){1827 g_mcloud_agent.dev_passwd_set({sn:g_selectedDevice.name,is_guest:0,old_pass:g_default_pass_input.value,new_pass:"123456"},null,function(msg,ref){1828 if(msg.result=="permission.denied"){1829 g_mcloud_agent.nick_set({sn:g_selectedDevice.name,name:g_selectedDevice.name},null,function(msg,ref){1830 if(msg.result=="permission.denied"){1831 g_mcloud_agent.osd_set({sn:g_selectedDevice.name,text:"anlory1",text_enable:1,date_enable:1,week_enable:1,date_format:"YYYY-MM-DD",time_12h:0,time_enable:1},null,function(msg,ref){1832 if(msg.result=="permission.denied"){1833 g_mcloud_agent.alarm_trigger_set({sn:g_selectedDevice.name,io_input:'Open',io_output:'Open',sensitivity:'112',night_sensitivity:'-12'},null,function(msg,ref){1834 if(msg.result=="permission.denied"){1835 var actions = {token:'motion_alert',enable:0,name:"motion_alert",srcs:[{devs:"motion"}],io_out_enable:0,snapshot_enable:1,record_enbale:1,snapshot_interval:0,pre_record_time:"3",io_alert_time:"3"};1836 g_mcloud_agent.alarm_action_set({sn:g_selectedDevice.name,enable:0,actions:actions},null,function(msg,ref){1837 if(msg.result=="permission.denied"){1838 g_mcloud_agent.time_set({sn:g_selectedDevice.name,type:'manually',auto_sync:0,ntp_addr:"210.72.145.44",timezone:"UTC+09:00",hour:'5',min:'5',sec:'5',year:'2005',mon:'5',day:'5'},null,function(msg,ref){1839 if(msg.result=="permission.denied"){1840 g_mcloud_agent.audio_set({sn:g_selectedDevice.name,speaker_level:33,mic_level:33},null,function(msg,ref){1841 if(msg.result=="permission.denied"){1842 g_mcloud_agent.record_set({sn:g_selectedDevice.name,enable:1,full_time:0,times:[{wday:127,start:1200,end:5400}]},null,function(msg,ref){1843 if(msg.result=="permission.denied"){1844 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,brightness:'121',contrast:'-61',color_saturation:'71',sharpness:'8',day_night:'auto',resetreset:0,flip:0,flicker_freq:0},null,function(msg,ref){1845 if(msg.result=="permission.denied"){1846 g_mcloud_agent.cam_set({sn:g_selectedDevice.name,token:"p0"},null,function(msg,ref){1847 if(msg.result=="permission.denied"){1848 add_test_li("test_guest",1);1849 test_next("guest");1850 }else{1851 add_test_li("test_guest",msg.result);1852 test_next("guest");1853 }1854 });1855 }else{1856 add_test_li("test_guest",msg.result);1857 test_next("guest");1858 }1859 });1860 }else{1861 add_test_li("test_guest",msg.result);1862 test_next("guest");1863 }1864 });1865 }else{1866 add_test_li("test_guest",msg.result);1867 test_next("guest");1868 }1869 });1870 }else{1871 add_test_li("test_guest",msg.result);1872 test_next("guest");1873 }1874 });1875 }else{1876 add_test_li("test_guest",msg.result);1877 test_next("guest");1878 }1879 });1880 }else{1881 add_test_li("test_guest",msg.result);1882 test_next("guest");1883 }1884 });1885 }else{1886 add_test_li("test_guest",msg.result);1887 test_next("guest");1888 }1889 });1890 }else{1891 add_test_li("test_guest",msg.result);1892 test_next("guest");1893 }1894 });1895 }else{1896 add_test_li("test_guest",msg.result);1897 test_next("guest");1898 }1899 });1900 }else{1901 add_test_li("test_guest",msg.result);1902 test_next("guest");1903 }1904 });1905 }else{1906 add_test_li("test_guest",msg.result);1907 test_next("guest");1908 }1909 });1910 }1911 function test_box_(){1912 add_test_li("test_box",0);1913 var erase_time;1914 var l_currentDate = new Date();1915 l_current_year=l_currentDate.getFullYear();1916 l_current_month= l_currentDate.getMonth() + 1;1917 l_current_day = l_currentDate.getDate();1918 st_time = ((new Date(l_current_year+"/"+l_current_month+"/"+l_current_day+" 00:00:00")).getTime());1919 en_time = st_time + 60*60*24*1000 ;1920 // add_test_li("test_box",st_time+"\r\n"+en_time);1921 g_mcloud_agent.box_get({box_sn:g_selectedDevice.name,dev_sn:"1jfiegbpxgzhq",flag:4,start_time:st_time,end_time:en_time},null,function(msg,ref) {1922 if(msg.result==""){1923 erase_time = msg.segs[0].stm;1924 // add_test_li("test_box",msg.segs);1925 g_mcloud_agent.box_set({sn:g_selectedDevice.name,dev_sn:"1jfiegbpxgzhq",cmd:"erase",start_time:msg.segs[0].stm,end_time:msg.segs[0].etm},null,function(msg,ref){1926 if(msg.result==""){1927 g_mcloud_agent.box_get({box_sn:g_selectedDevice.name,dev_sn:"1jfiegbpxgzhq",flag:4,start_time:st_time,end_time:en_time},null,function(msg,ref) {1928 if(msg.result==""){1929 if(erase_time == msg.segs[0].stm){1930 add_test_li("test_box","删除失败");1931 }else1932 {1933 add_test_li("test_box",1);1934 }1935 test_next("box");1936 }else{1937 add_test_li("test_box",msg.result);1938 test_next("box");1939 }1940 });1941 }else{1942 add_test_li("test_box",msg.result);1943 test_next("box");1944 }1945 });1946 }else{1947 add_test_li("test_box",msg.result);1948 test_next("box");1949 }1950 });1951 }1952 function auto_test () {1953 g_auto_test_flag=1;1954 var i=0;1955 g_test_select.splice(0,g_test_select.length);//clear array g_test_select1956 if(select_checkbox.checked || test_direct.checked)1957 g_test_select[i++]='direct';1958 if(select_checkbox.checked|| test_dev_start.checked)1959 g_test_select[i++]='dev_start';1960 if(select_checkbox.checked|| test_date_syn.checked)1961 g_test_select[i++]='date_syn';1962 if(select_checkbox.checked|| test_sys_timezone.checked)...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1var request = require('request');2var fs = require('fs');3var Promise = require('bluebird');4var path = require('path');5const Joi = require('@hapi/joi');6const Lab = require('@hapi/lab');7const lab = exports.lab = Lab.script();8const Code = require('@hapi/code');9const expect = Code.expect;10const _ = require('underscore');11const md5File = require('md5-file')12var DCBIALib = require("./index");13var agentOptions = {};14var token = {}15var joiokres = Joi.object().keys({16 ok: Joi.boolean().valid(true),17 id: Joi.string(),18 rev: Joi.string()19 });20var dcbia = new DCBIALib();21dcbia.setAgentOptions({22 rejectUnauthorized: false23})24dcbia.setServer("http://localhost:8180")25lab.experiment("Test dcbia lib", function(){26 var user = {27 email: "jprieto@med.unc.edu",28 password: "123TestTest!"29 }30 var clinicaldatapost = {31 "patientId": "Patient1",32 "type": "clinicalData",33 "formId": "TMJSurvey",34 "scope": ["dentist"],35 "date": "2016-12-17",36 "owner": "emailaddress@dentist.com"37 }38 var wrongScopeClinicalDatapost = {39 "patientId": "Patient1",40 "type": "clinicalData",41 "formId": "TMJSurvey",42 "scope": ["wrongScope"],43 "date": "2016-12-17",44 "owner": "emailaddress@dentist.com"45 }46 var id = "";47 var idWrongScope = "";48 // lab.test('returns true when new user is login.', function(){49 // return dcbia.userLogin({email: "juanprietob@gmail.com", "password": "808BuitragoK-9!"})50 // .then(function(res){51 // Joi.assert(res.token, Joi.string().required());52 // });53 54 // });55 // lab.test('returns true when a whole directory structure is created', function(){56 57 // var directory_root = 10;58 59 // var root_dir = 'my_deep_test_subjects';60 // const create_recursive = (path_current)=>{61 // fs.mkdirSync(path_current, {recursive: true});62 // var full_path = path.join(path_current, _.uniqueId("T1") + ".nrrd")63 // fs.writeFileSync(full_path, _.uniqueId("Some text"));64 // full_path = path.join(path_current, _.uniqueId("T2") + ".nrrd")65 // fs.writeFileSync(full_path, _.uniqueId("Some text"));66 // full_path = path.join(path_current, _.uniqueId("FA") + ".nrrd")67 // fs.writeFileSync(full_path, _.uniqueId("Some text"));68 69 // }70 // _.map(_.range(directory_root), (r)=>{71 // var path_current = path.join(root_dir, _.uniqueId("d"));72 73 // create_recursive(path_current);74 // });75 76 // });77 // lab.test('returns true when user upload a directory', function(){78 79 // var dirname = 'my_deep_test_subjects';80 // var target = 'test/my_deep_test_subjects/';81 // return dcbia.uploadDirectory(target, dirname)82 // .then(function(res){83 // expect(res).to.be.an.array().to.include('File uploaded!');84 // }); 85 // });86 lab.test('returns true when new user is login.', function(){87 return dcbia.userLogin(user)88 .then(function(res){89 Joi.assert(res.token, Joi.string().required());90 });91 92 });93 // lab.test('returns true if the document is posted.', function(){94 // return dcbia.createClinicalData(clinicaldatapost)95 // .then(function(res){96 // console.log(res)97 98 // });99 100 // });101 // lab.test('returns true when return the surveys owners.', function(){102 // return dcbia.getClinicalDataOwners()103 // .then(function(res){104 // Code.expect(JSON.parse(res).length > 0).to.be.true();105 // });106 107 // });108 // lab.test('returns true when return the right owner.', function(){109 // return dcbia.getClinicalDataOwner("emailaddress@dentist.com")110 // .then(function(res){111 // Code.expect(JSON.parse(res)[0]["_id"] === id).to.be.true();112 // });113 114 // });115 // lab.test('returns true when the user scope fits the document scope.', function(){116 // return dcbia.getClinicalDataWithId(token,id)117 // .then(function(res){118 // Code.expect(JSON.parse(res).hasOwnProperty('error')).to.be.false();119 // });120 121 // });122 // lab.test('returns true when the user scope does not fit the document scope.', function(){123 // return dcbia.createClinicalData(token,wrongScopeClinicalDatapost)124 // .then(function(res){125 // idWrongScope = res["id"];126 // });127 // return getClinicalDataWithId(token,idWrongScope)128 // .then(function(res){129 // Code.expect(JSON.parse(res).hasOwnProperty('error')).to.be.true();130 // });131 132 // });133 // lab.test('returns true if the document is deleted.', function(){134 // return dcbia.deleteClinicalData(token,id)135 // .then(function(res){136 // Code.expect(JSON.parse(res)["ok"]).to.be.true();137 // });138 139 // });140 // lab.test('returns true if the document is deleted.', function(){141 // return dcbia.deleteClinicalData(token,idWrongScope)142 // .then(function(res){143 // Code.expect(JSON.parse(res)["ok"]).to.be.true();144 // }); 145 // });146/////////////////////////////////////////////////147 lab.test('returns true when user folder map exist', function(){148 return dcbia.getDirectoryMap()149 .then(function(res){150 expect(res).to.be.an.array()151 }); 152 });153 lab.test('returns true when user upload a file', function(){154 155 var filename = 'filetest.txt';156 var target = 'test/filetest.txt';157 if(!fs.existsSync(filename)){158 fs.writeFileSync(filename, "This is some data for the test file");159 }160 return dcbia.upload(target, filename)161 .then(function(res){162 expect(res).to.equal('File uploaded!')163 }); 164 });165 lab.test('returns true when user upload a file that does not exist', function(){166 167 var filename = 'filetest_does_not_exists.txt';168 var target = 'test/filetest_does_not_exists.txt';169 return dcbia.upload(target, filename)170 .catch(function(err){171 expect(err).to.be.an.error(Error)172 }); 173 });174 var newfolder = 'test/foldername'175 lab.test('returns true when user creates a new folder', function(){176 return dcbia.createFolder(newfolder)177 .then(function(res){178 expect(res).to.equal('true');179 }); 180 });181 lab.test('returns false when user try to create an existing folder', function(){182 return dcbia.createFolder(newfolder)183 .then(function(res){184 expect(res).to.equal('false');185 }); 186 });187 var fileToDelete = 'test'188 lab.test('returns true when user delete a folder', function(){189 return dcbia.deleteFile(fileToDelete)190 .then(function(res){191 expect(res).to.equal('File deleted!')192 }); 193 });194 lab.test('returns true when a whole directory structure is created', function(){195 196 var directory_root = 3;197 var directory_deep = 3;198 var files_directory = 3;199 var root_dir = 'my_deep_test';200 const create_recursive = (path_current, current_directory_deep)=>{201 fs.mkdirSync(path_current, {recursive: true});202 _.map(_.range(files_directory), ()=>{203 var full_path = path.join(path_current, _.uniqueId("f"))204 fs.writeFileSync(full_path, _.uniqueId("Some text"));205 });206 current_directory_deep--;207 if(current_directory_deep > 0){208 create_recursive(path.join(path_current, _.uniqueId("d d")), current_directory_deep) 209 }210 }211 _.map(_.range(directory_root), (r)=>{212 var path_current = path.join(root_dir, _.uniqueId("d"));213 214 create_recursive(path_current, directory_deep);215 });216 217 });218 lab.test('returns true when user upload a directory', function(){219 220 var dirname = 'my_deep_test';221 var target = 'test/my_deep_test/';222 return dcbia.uploadDirectory(target, dirname)223 .then(function(res){224 expect(res).to.be.an.array().to.include('File uploaded!');225 }); 226 });227 lab.test('returns true when user download a directory one file by one', function(){228 return dcbia.getDirectoryMap()229 .then((dirmap)=>{230 var file_list = _.filter(dcbia.flattenDirectoryMap(dirmap), (fname)=>{231 return fname.match(new RegExp("test/my_deep_test"));232 });233 234 return Promise.map(file_list, (filename)=>{235 return new Promise((resolve, reject)=>{236 237 var rstream = dcbia.downloadFileStream(filename);238 var writer = fs.createWriteStream("temp_file");239 240 rstream.pipe(writer);241 writer.on('finish', ()=>{242 var orig_filename = filename.replace('test/', '');243 return Promise.all([md5File("temp_file"), md5File(orig_filename)])244 .spread((temp_hash, orig_hash)=>{245 expect(temp_hash).to.include(orig_hash);246 fs.unlinkSync("temp_file");247 resolve();248 })249 250 });251 });252 }, {concurrency: 1});253 }); 254 });255 lab.test('returns true when user download a whole directory', function(){256 return Promise.resolve(dcbia.downloadFileStream("test/my_deep_test/"))257 .then(function(res){258 return new Promise((resolve, reject)=>{259 var writer = fs.createWriteStream("my_deep_test.zip");260 261 res.pipe(writer);262 writer.on('finish', ()=>{263 md5File("my_deep_test.zip").then((hash) => {264 expect(hash).to.be.string();265 fs.unlinkSync("my_deep_test.zip");266 resolve();267 });268 })269 });270 }); 271 });272 lab.test('returns true when user copy a whole directory', function(){273 var copy_obj = {274 source: 'test/my_deep_test',275 target: 'my_deep_test_copy/inner_copy'276 }277 return dcbia.copyFiles(copy_obj)278 .then(function(res){279 expect(res).to.be.true();280 }); 281 });282 lab.test('returns true when user deletes a whole directory', function(){283 return dcbia.deleteFile("my_deep_test_copy")284 .then(function(res){285 expect(res).to.equal('File deleted!')286 }); 287 });288 lab.test('returns true when user copy a file into a non existant directory', function(){289 var copy_obj = {290 source: 'test/my_deep_test/d22/d d29/d d36/f41',291 target: 'my_deep_test_copy_single_file/'292 }293 return dcbia.copyFiles(copy_obj)294 .then(function(res){295 expect(res).to.be.an.object().to.include({statusCode: 400});296 }); 297 });298 lab.test('returns true when user copy a file', function(){299 var copy_obj = {300 source: 'test/my_deep_test/d22/d d29/d d36/f41',301 target: 'my_deep_test_copy_single_file_f41'302 }303 return dcbia.copyFiles(copy_obj)304 .then(function(res){305 expect(res).to.be.true();306 }); 307 });308 lab.test('returns true when user copy a file into existing directory', function(){309 var copy_obj = {310 source: 'test/my_deep_test/d22/d d29/d d36/f41',311 target: 'test/my_deep_test/'312 }313 return dcbia.copyFiles(copy_obj)314 .then(function(res){315 expect(res).to.be.true();316 }); 317 });318 lab.test('returns true when user copy a file relative path', function(){319 var copy_obj = {320 source: 'test/my_deep_test/d22/d d29/d d36/f41',321 target: '../my_deep_test_copy_single_file_f41'322 }323 return dcbia.copyFiles(copy_obj)324 .then(function(res){325 expect(res).to.be.an.object().to.include({statusCode: 400});326 }); 327 });328 lab.test('returns true when user deletes a file with relative path', function(){329 return dcbia.deleteFile("../my_deep_test_copy_single_file_f41")330 .then(function(res){331 expect(res).to.be.an.object().to.include({statusCode: 404});332 }); 333 });334 lab.test('returns true when user deletes a file', function(){335 return dcbia.deleteFile("my_deep_test_copy_single_file_f41")336 .then(function(res){337 expect(res).to.equal('File deleted!')338 }); 339 });340 lab.test('returns true when user moves a file to another directory', function(){341 var infos = {342 source: 'test/my_deep_test/d22/d d29/d d36/f41',343 target: 'test/'344 }345 return dcbia.moveFiles(infos)346 .then(function(res){347 expect(res).to.be.true();348 }); 349 });350 lab.test('returns true when user moves a whole directory to another directory', function(){351 var infos = {352 source: 'test/my_deep_test',353 target: 'test_next/'354 }355 return dcbia.createFolder("test_next")356 .then(()=>{357 return dcbia.moveFiles(infos)358 .then(function(res){359 expect(res).to.be.true();360 }); 361 })362 363 });364 lab.test('returns true when user moves a whole directory with relative path', function(){365 var infos = {366 source: 'test/my_deep_test',367 target: 'test_next/../'368 }369 return dcbia.createFolder("test_next")370 .then(()=>{371 return dcbia.moveFiles(infos)372 .then(function(res){373 expect(res).to.be.an.object().to.include({statusCode: 400});374 }); 375 })376 377 });378 379 lab.test('returns true when user share a folder with a user', function(){380 var infos = {381 users: ['juanprietob@gmail.com'],382 directory: "test_next/my_deep_test/d22"383 }384 return dcbia.shareFiles(infos)385 .then(function(res){386 expect(res).to.part.include({ ok: true });387 });388 });389 lab.test('returns true when user gets the shared doc', function(){390 return dcbia.myShareFiles("test_next/my_deep_test/d22")391 .then(function(res){392 expect(res).to.satisfy((r)=>{393 return r.type == "shared" && expect(r.users).to.include("juanprietob@gmail.com");394 });395 });396 });397 lab.test('returns false when user unshare folder with a user', function(){398 var infos = {399 users: ['juanprietob@gmail.com'],400 directory: "test_next/my_deep_test/d22"401 }402 return dcbia.unshareFiles(infos)403 .then(function(res){404 expect(res).to.part.include({ ok: true });405 });406 });407 lab.test('returns true when user gets the shared doc and user is not there', function(){408 return dcbia.myShareFiles("test_next/my_deep_test/d22")409 .then(function(res){410 expect(res).to.satisfy((r)=>{411 return r.type == "shared" && expect(r.users).to.not.include("juanprietob@gmail.com");412 });413 });414 });415 lab.test('returns true when user gets list of shared of folder that does not exist', function(){416 return dcbia.myShareFiles("test_next_does_not/exist")417 .then(function(res){418 expect(res).to.be.an.object().to.include({statusCode: 404});419 });420 });421 lab.test('returns false when user share a folder with self', function(){422 var infos = {423 users: ['sbrosset@umich.edu'],424 directory: "test_next"425 }426 return dcbia.shareFiles(infos)427 .then(function(res){428 expect(res).to.be.an.object().to.include({statusCode: 400});429 });430 });431 lab.test('returns false when user downloads shared Folder', function(){432 return Promise.resolve(dcbia.downloadFileStream("sharedFiles/test_next"))433 .then(function(res){434 return new Promise((resolve, reject)=>{435 var writer = fs.createWriteStream("my_shared_deep_test.zip");436 437 res.pipe(writer);438 writer.on('finish', ()=>{439 md5File("my_shared_deep_test.zip").then((hash) => {440 expect(hash).to.be.string();441 fs.unlinkSync("my_shared_deep_test.zip");442 resolve();443 });444 })445 });446 }); 447 });448 lab.test('returns true when user deletes deep_test', function(){449 return dcbia.deleteFile("test_next")450 .then(function(res){451 expect(res).to.equal('File deleted!')452 }); 453 });...

Full Screen

Full Screen

readernext.py

Source:readernext.py Github

copy

Full Screen

1#!/usr/bin/python -u2# -*- coding: ISO-8859-1 -*-3#4# this tests the next API of the XmlTextReader interface5#6import libxml27import StringIO8import sys9# Memory debug specific10libxml2.debugMemory(1)11f = StringIO.StringIO("""<a><b><c /></b><d>content of d</d></a>""")12input = libxml2.inputBuffer(f)13reader = input.newTextReader("test_next")14ret = reader.Read()15if ret != 1:16 print "test_next: Error reading to first element"17 sys.exit(1)18if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \19 reader.NodeType() != 1 or reader.HasAttributes() != 0:20 print "test_next: Error reading the first element"21 sys.exit(1)22ret = reader.Read()23if ret != 1:24 print "test_next: Error reading to second element"25 sys.exit(1)26if reader.Name() != "b" or reader.IsEmptyElement() != 0 or \27 reader.NodeType() != 1 or reader.HasAttributes() != 0:28 print "test_next: Error reading the second element"29 sys.exit(1)30ret = reader.Read()31if ret != 1:32 print "test_next: Error reading to third element"33 sys.exit(1)34if reader.Name() != "c" or reader.NodeType() != 1 or \35 reader.HasAttributes() != 0:36 print "test_next: Error reading the third element"37 sys.exit(1)38ret = reader.Read()39if ret != 1:40 print "test_next: Error reading to end of third element"41 sys.exit(1)42if reader.Name() != "b" or reader.NodeType() != 15:43 print "test_next: Error reading to end of second element"44 sys.exit(1)45ret = reader.Next()46if ret != 1:47 print "test_next: Error moving to third element"48 sys.exit(1)49if reader.Name() != "d" or reader.IsEmptyElement() != 0 or \50 reader.NodeType() != 1 or reader.HasAttributes() != 0:51 print "test_next: Error reading third element"52 sys.exit(1)53ret = reader.Next()54if ret != 1:55 print "test_next: Error reading to end of first element"56 sys.exit(1)57if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \58 reader.NodeType() != 15 or reader.HasAttributes() != 0:59 print "test_next: Error reading the end of first element"60 sys.exit(1)61ret = reader.Read()62if ret != 0:63 print "test_next: Error reading to end of document"64 sys.exit(1)65#66# cleanup for memory allocation counting67#68del f69del input70del reader71# Memory debug specific72libxml2.cleanupParser()73if libxml2.debugMemory(1) == 0:74 print "OK"75else:76 print "Memory leak %d bytes" % (libxml2.debugMemory(1))...

Full Screen

Full Screen

next.config.js

Source:next.config.js Github

copy

Full Screen

1/*2 * @Description:3 * @Version: 2.04 * @Autor: 匡光淼5 * @Date: 2022-07-19 08:06:236 * @LastEditors: 匡光淼7 * @LastEditTime: 2022-07-28 20:57:458 */9/** @type {import('next').NextConfig} */10const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_SERVER, PHASE_PRODUCTION_BUILD } = require('next/constants')11module.exports = (phase) => {12 /**13 npm run dev: phase-development-server14 npm run build: phase-production-build15 npm run start: phase-production-server16 */17 console.log(phase, '----', PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_SERVER, PHASE_PRODUCTION_BUILD)18 let config = {19 reactStrictMode: true,20 swcMinify: true // 不适用swc打包()21 }22 if (phase === PHASE_DEVELOPMENT_SERVER) {23 // 开发环境24 Object.assign(config, {25 env: {26 mongodb_username: 'test_next',27 mongodb_password: 'kgm0515',28 mongodb_ip: '120.76.74.224',29 mongodb_port: '27017',30 mongodb_database: 'test_next'31 }32 })33 } else {34 Object.assign(config, {35 env: {36 mongodb_username: 'test_next',37 mongodb_password: 'kgm0515',38 mongodb_ip: '120.76.74.224',39 mongodb_port: '27017',40 mongodb_database: 'test_next'41 }42 })43 }44 return config...

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