Best Python code snippet using autotest_python
test_info_handler.py
Source:test_info_handler.py
...129 Database.set_meta("start_time", now)130 Database.set_meta("contest_duration", 1000)131 Database.set_meta("window_duration", 100)132 Database.add_user("token", "", "")133 Database.set_start_delay("token", 10)134 Database.add_task("poldo", "", "", 42, 1)135 Database.add_user_task("token", "poldo")136 Database.add_input("inputid", "token", "poldo", 1, "/path", 42)137 Database.set_user_attempt("token", "poldo", 1)138 res = self.handler.get_user(token="token", _ip="1.1.1.1")139 end_time = datetime.fromtimestamp(now + 110, timezone.utc).isoformat()140 self.assertEqual(end_time, res["end_time"])141 def test_get_user_windowed_almost_finished(self):142 now = int(datetime.utcnow().timestamp())143 Database.set_meta("start_time", now - 90)144 Database.set_meta("contest_duration", 1000)145 Database.set_meta("window_duration", 100)146 Database.add_user("token", "", "")147 Database.set_start_delay("token", 10)148 Database.add_task("poldo", "", "", 42, 1)149 Database.add_user_task("token", "poldo")150 Database.add_input("inputid", "token", "poldo", 1, "/path", 42)151 Database.set_user_attempt("token", "poldo", 1)152 res = self.handler.get_user(token="token", _ip="1.1.1.1")153 end_time = datetime.fromtimestamp(now + 20, timezone.utc).isoformat()154 self.assertEqual(end_time, res["end_time"])155 def test_get_user_windowed_partial_window(self):156 now = int(datetime.utcnow().timestamp())157 Database.set_meta("start_time", now)158 Database.set_meta("contest_duration", 1000)159 Database.set_meta("window_duration", 100)160 Database.add_user("token", "", "")161 Database.set_start_delay("token", 990)162 Database.add_task("poldo", "", "", 42, 1)163 Database.add_user_task("token", "poldo")164 Database.add_input("inputid", "token", "poldo", 1, "/path", 42)165 Database.set_user_attempt("token", "poldo", 1)166 res = self.handler.get_user(token="token", _ip="1.1.1.1")167 end_time = datetime.fromtimestamp(now + 1000, timezone.utc).isoformat()168 self.assertEqual(end_time, res["end_time"])169 def test_get_user_no_current_attempt(self):170 Utils.start_contest(since=100, duration=200)171 Database.add_user("token", "", "")172 Database.add_task("poldo", "", "", 42, 1)173 Database.add_user_task("token", "poldo")174 res = self.handler.get_user(token="token", _ip="1.1.1.1")175 self.assertEqual(None, res["tasks"]["poldo"]["current_input"])...
ad9102_tool.py
Source:ad9102_tool.py
...220 line = line.replace(' ', ',')221 self.ad9102.set_phase(*list(eval(line)))222223 @handle_errors224 def do_set_start_delay(self, line):225 '''set_start_delay'''226 if '?' == line:227 print(get_function_doc(self))228 return None229230 line = line.replace(' ', ',')231 self.ad9102.set_start_delay(*list(eval(line)))232233 @handle_errors234 def do_set_sram_addr(self, line):235 '''set_sram_addr'''236 if '?' == line:237 print(get_function_doc(self))238 return None239240 line = line.replace(' ', ',')241 self.ad9102.set_sram_addr(*list(eval(line)))242243 @handle_errors244 def do_set_dds_cycles(self, line):245 '''set_dds_cycles'''
...
camera_handler.py
Source:camera_handler.py
...11 self.camera = PiCamera()12 self.camera.resolution = (160, 120)13 self.camera.color_effects = (128, 128)14 self.img_root = "img/"15 def set_start_delay(self, delay):16 """Set start delay."""17 self.start_delay = delay18 def set_img_root(self, location):19 """Set location where images are being saved."""20 self.img_root = location21 def take_image(self):22 """Take single image."""23 time_str = datetime.utcnow().strftime('%Y%m%d-%H_%M_%S_%f')[:-3]24 img_path = self.img_root + "img" + time_str + ".png"25 self.camera.capture(img_path)26 self.logger.info('saved image to path: ' + img_path)...
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!!