Best Python code snippet using Airtest
collect_handle.py
Source: collect_handle.py
...23def get_all_app_no_virtual():24 # è·åææåºç¨é宿主æºç个æ°25 ret = models.IDCPhysical.objects.filter(server_type=u"é宿主æº").count()26 return ret27def get_no_user_device_status():28 # è·åææä¸çº¿æ¥åºçæ°é29 ret = models.IDCPhysical.objects.filter(device_status__in=[u"ä¸çº¿", u"æ¥åº"]).count()30 return ret31def get_all_vhost_online():32 # è·åææ宿主æºãå¨çº¿çæ°é33 ret = models.IDCPhysical.objects.filter(server_type=u"宿主æº", device_status=u"å¨çº¿").count()34 return ret35def get_all_host_online():36 # è·åææé宿主æºãå¨çº¿çæ°é37 ret = models.IDCPhysical.objects.filter(server_type=u"é宿主æº", device_status=u"å¨çº¿").count()38 return ret39def get_all_host_downline():40 # è·åææé宿主æºãä¸çº¿çæ°é41 ret = models.IDCPhysical.objects.filter(server_type=u"é宿主æº", device_status=u"ä¸çº¿").count()42 return ret43def get_all_vhost_downline():44 # è·åææ宿主æºãä¸çº¿çæ°é45 ret = models.IDCPhysical.objects.filter(server_type=u"宿主æº", device_status=u"ä¸çº¿").count()46 return ret47def get_all_host_not_use():48 # è·åææé宿主æºãæ¥åºçæ°é49 ret = models.IDCPhysical.objects.filter(server_type=u"é宿主æº", device_status=u"æ¥åº").count()50 return ret51def get_all_vhost_not_use():52 # è·åææ宿主æºãæ¥åºçæ°é53 ret = models.IDCPhysical.objects.filter(server_type=u"宿主æº", device_status=u"æ¥åº").count()54 return ret55def get_can_virtual_online():56 # è·åææå¯èæåãå¨çº¿çæ°é57 ret = models.IDCPhysical.objects.filter(is_virtual=u"æ¯", device_status=u"å¨çº¿").count()58 return ret59def get_can_virtual_offline():60 # è·åææå¯èæåãä¸çº¿çæ°é61 ret = models.IDCPhysical.objects.filter(is_virtual=u"æ¯", device_status=u"ä¸çº¿").count()62 return ret63def get_can_virtual_scrap():64 # è·åææå¯èæåãæ¥åºçæ°é65 ret = models.IDCPhysical.objects.filter(is_virtual=u"æ¯", device_status=u"æ¥åº").count()66 return ret67def get_not_virtual_online():68 # è·åææå¯èæåãå¨çº¿çæ°é69 ret = models.IDCPhysical.objects.filter(is_virtual=u"å¦", device_status=u"å¨çº¿").count()70 return ret71def get_not_virtual_offline():72 # è·åææå¯èæåãä¸çº¿çæ°é73 ret = models.IDCPhysical.objects.filter(is_virtual=u"å¦", device_status=u"ä¸çº¿").count()74 return ret75def get_not_virtual_scrap():76 # è·åææå¯èæåãæ¥åºçæ°é77 ret = models.IDCPhysical.objects.filter(is_virtual=u"å¦", device_status=u"æ¥åº").count()78 return ret79def get_idc_device_status(idc_name):80 # è·åå个æºæ¿ä¸åç¶æç设å¤æ°é ï¼å¨çº¿ ä¸çº¿ æ¥åºï¼81 online = models.IDCPhysical.objects.filter(idc=idc_name, device_status=u"å¨çº¿").count()82 offline = models.IDCPhysical.objects.filter(idc=idc_name, device_status=u"ä¸çº¿").count()83 scrap = models.IDCPhysical.objects.filter(idc=idc_name, device_status=u"æ¥åº").count()84 return online, offline, scrap85def get_brand_status(device_name):86 # è·åå个åçæå¡å¨ä¸åç¶æç设å¤æ°é ï¼å¨çº¿ ä¸çº¿ æ¥åºï¼87 online = models.IDCPhysical.objects.filter(brand=device_name, device_status=u"å¨çº¿").count()88 offline = models.IDCPhysical.objects.filter(brand=device_name, device_status=u"ä¸çº¿").count()89 scrap = models.IDCPhysical.objects.filter(brand=device_name, device_status=u"æ¥åº").count()...
app.py
Source: app.py
1import logging2import boto33import uuid4import json5logger = logging.getLogger()6logger.setLevel(logging.ERROR)7def lambda_handler(event, context):8 thing_name = event['thing_name']9 timestamp = event['update']['timestamp']10 current_record = event['update']['current']['state']['desired']11 if 'device_status' not in current_record:12 logger.error('Shadow has no "device_status" field')13 return { 'statusCode': 200 }14 else:15 device_status = current_record['device_status']16 logger.info('Thing: %s State: %s Time: %s', thing_name, current_record, timestamp)17 iot_client = boto3.client('iotanalytics')18 uid = uuid.uuid4()19 entry = {}20 entry['thing_name'] = thing_name21 entry['timestamp'] = timestamp22 if 'last_gps_location' in device_status:23 gps = device_status['last_gps_location']24 entry['last_gps_fix_longitude'] = gps['longitude']25 entry['last_gps_fix_latitude'] = gps['latitude']26 entry['last_gps_fix_time'] = gps['timestamp']27 if 'last_cellular_connected_timestamp' in device_status:28 ts = device_status['last_cellular_connected_timestamp']29 entry['last_cellular_connection'] = ts30 if 'last_sat_tx_timestamp' in device_status:31 ts = device_status['last_sat_tx_timestamp']32 entry['last_sat_tx'] = ts33 if 'next_sat_tx_timestamp' in device_status:34 ts = device_status['next_sat_tx_timestamp']35 entry['next_sat_tx'] = ts36 if 'battery_level' in device_status:37 n = device_status['battery_level']38 entry['battery_level'] = n39 if 'battery_voltage' in device_status:40 n = device_status['battery_voltage']41 entry['battery_voltage'] = n42 if 'configuration_version' in device_status:43 n = device_status['configuration_version']44 entry['config_version'] = n45 if 'firmware_version' in device_status:46 n = device_status['firmware_version']47 entry['fw_version'] = n48 if 'last_log_file_read_pos' in device_status:49 n = device_status['last_log_file_read_pos']50 entry['last_log_read_pos'] = n51 resp = iot_client.batch_put_message(channelName='arribada_device_status',52 messages=[{53 'messageId': str(uid),54 'payload': json.dumps(entry)55 }56 ])57 logger.debug('resp=%s', resp)...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!