Best Python code snippet using lisa_python
test_api_varp.py
Source:test_api_varp.py
...73 cmds = 'no ip virtual-router mac-address'74 self.eapi_positive_config_test(func, cmds)75 def test_set_mac_address_with_no_value(self):76 with self.assertRaises(ValueError):77 self.instance.set_mac_address(mac_address=None)78 def test_set_mac_address_with_bad_value(self):79 with self.assertRaises(ValueError):80 self.instance.set_mac_address(mac_address='0011.2233.4455')81 def test_set_mac_address_with_default(self):82 func = function('set_mac_address', default=True)83 cmds = 'default ip virtual-router mac-address'84 self.eapi_positive_config_test(func, cmds)85class TestApiVarpInterfaces(EapiConfigUnitTest):86 def __init__(self, *args, **kwargs):87 super(TestApiVarpInterfaces, self).__init__(*args, **kwargs)88 self.instance = pyeapi.api.varp.VarpInterfaces(None)89 self.config = open(get_fixture('running_config.varp')).read()90 def test_get_with_no_interface(self):91 self.config = ""92 self.setUp()93 result = self.instance.get('Vlan1000')94 self.assertIsNone(result)...
broadcaster.py
Source:broadcaster.py
...13def set_broadcast_rate():14 print("Set Rate")15 subprocess.run("hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00", shell=True)16 time.sleep(0.1)17def set_mac_address():18 # OLD MAC: 5C:F3:70:9C:52:6219 print("Change MAC")20 subprocess.run("hcitool cmd 0x3f 0x001 0x54 0x53 0x9c 0x70 0xf3 0xc0", shell=True)21 time.sleep(0.1)22def set_broadcast_advdata(data):23 print("Set Data")24 # base_cmd = ['hcitool', '-i', 'hci0', 'cmd', '0x08', '0x0008', '11', '02', '01', '1a', '0d', 'ff']25 # set_broadcast_advdata(['E0', '02', '48', '45', '4c', '4c', '4f', '57', '4f', '52', '4c', '44'])26 base_cmd = ['hcitool', '-i', 'hci0', 'cmd', '0x08', '0x0008', '1f', '02', '01', '06', '1b', 'ff']27 base_cmd.extend(data)28 subprocess.run(base_cmd)29 time.sleep(0.1)30#* payload[2] = LW_speed,31#* payload[3] = LW_dir32#* payload[4] = RW_speed,33#* payload[5] = RW_dir34#* payload[6] = Switch (Not used)35#* payload[7] = Lift_PWM (Not used)36#* payload[8] = Tilt_PWM (Not used)37#* payload[9] = Gripper_bool38#* payload[10] = Lift_speed_tick39#* payload[11] = Lift_speed_dir40#* payload[12] = Tilt_speed_tick41#* payload[13] = Tilt_speed_dir42def main_test_changing_ws():43 lw_speed = 044 payload = ['ff'] * 2645 payload[0] = 'e0'46 payload[1] = '02'47 payload[2] = '00'48 payload[3] = '00'49 stop_broadcasting()50 set_mac_address()51 set_broadcast_rate()52 start_broadcasting()53 for _ in range(50):54 print("===DATA-2 is %s" % payload[2])55 set_broadcast_advdata(payload)56 time.sleep(0.1)57 lw_speed += 158 payload[2] = "{:02x}".format(lw_speed)59 stop_broadcasting()60 print("END")61def main_test_arm_lift():62 data = ['ff'] * 2663 data[0] = 'e0'64 data[1] = '02'65 data[10] = '32'66 data[11] = '01'67 stop_broadcasting()68 set_mac_address()69 set_broadcast_rate()70 start_broadcasting()71 for _ in range(10):72 print("===DATA-11 is %s" % data[11])73 set_broadcast_advdata(data)74 time.sleep(3)75 if data[11] == '01':76 data[11] = '00'77 else:78 data[11] = '01'79 80 stop_broadcasting()81 print("END")82if __name__ == '__main__':...
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!!