Best Python code snippet using autotest_python
class-alert-bot.py
Source:class-alert-bot.py
...24 if cday=='Monday' or cday=='Wednesday': 25 embed = DiscordEmbed(title=mde, description=des, color='33ff00')26 embed.set_author(name='Maths')27 embed.set_footer(text='footer here'')28 embed.set_timestamp()29 webhook.add_embed(embed)30 webhook.execute()31 time.sleep(1800)32 continue;33 elif cday=='Tuesday': 34 embed = DiscordEmbed(title=psp, description=des, color='33ff00')35 embed.set_author(name='PSP')36 embed.set_footer(text='footer here'')37 embed.set_timestamp()38 webhook.add_embed(embed)39 webhook.execute()40 time.sleep(1800)41 continue;42 elif cday=='Thursday':43 embed = DiscordEmbed(title=che, description=des, color='33ff00')44 embed.set_author(name='Chemistry')45 embed.set_footer(text='footer here')46 embed.set_timestamp()47 webhook.add_embed(embed)48 webhook.execute()49 time.sleep(1800)50 continue;51 elif cday=='Friday':52 embed = DiscordEmbed(title=phy, description=des, color='33ff00')53 embed.set_author(name='Physics')54 embed.set_footer(text='footer here')55 embed.set_timestamp()56 webhook.add_embed(embed)57 webhook.execute()58 time.sleep(1800)59 continue;60 elif cday == 'Saturday':61 embed = DiscordEmbed(title=beee, description=des, color='33ff00')62 embed.set_author(name='BEEE')63 embed.set_footer(text='footer here')64 embed.set_timestamp()65 webhook.add_embed(embed)66 webhook.execute()67 time.sleep(1800)68 continue; 69 else:70 print("holiday. i'm sleeping for 6 hours")#change it to whatever you want71 time.sleep(21600)# in seconds72 elif ctime == '10:40:00': #2nd hour73 print("2nd class vro")74 if cday=='Monday': 75 embed = DiscordEmbed(title=eng, description=des, color='33ff00')76 embed.set_author(name='English')77 embed.set_footer(text='footer here')78 embed.set_timestamp()79 webhook.add_embed(embed)80 webhook.execute()81 time.sleep(1800)82 continue;83 elif cday=='Tuesday': 84 embed = DiscordEmbed(title=psp, description=des, color='33ff00')85 embed.set_author(name='PSP')86 embed.set_footer(text='footer here')87 embed.set_timestamp()88 webhook.add_embed(embed)89 webhook.execute()90 time.sleep(1800)91 continue;92 elif cday=='Wednesday': 93 embed = DiscordEmbed(title=phy, description=des, color='33ff00')94 embed.set_author(name='Physics')95 embed.set_footer(text='footer here')96 embed.set_timestamp()97 webhook.add_embed(embed)98 webhook.execute()99 time.sleep(1800)100 continue;101 elif cday=='Thursday':102 embed = DiscordEmbed(title=beee, description=des, color='33ff00')103 embed.set_author(name='BEEE')104 embed.set_footer(text='footer here')105 embed.set_timestamp()106 webhook.add_embed(embed)107 webhook.execute()108 time.sleep(1800)109 continue;110 elif cday=='Friday':111 embed = DiscordEmbed(title=mde, description=des, color='33ff00')112 embed.set_author(name='Maths')113 embed.set_footer(text='footer here')114 embed.set_timestamp()115 webhook.add_embed(embed)116 webhook.execute()117 time.sleep(1800)118 continue;119 elif cday == 'Saturday':120 embed = DiscordEmbed(title=che, description=des, color='33ff00')121 embed.set_author(name='Chemistry')122 embed.set_footer(text='footer here')123 embed.set_timestamp()124 webhook.add_embed(embed)125 webhook.execute()126 time.sleep(1800)127 continue; 128 else:129 print("Holiday :)")130 time.sleep(21600)131132 elif ctime == "11:35:00": #3rd hour133 print("3rd class")134 if cday=='Monday': 135 embed = DiscordEmbed(title=che, description=des, color='33ff00')136 embed.set_author(name='Chemistry')137 embed.set_footer(text='footer here')138 embed.set_timestamp()139 webhook.add_embed(embed)140 webhook.execute()141 time.sleep(1800)142 continue;143 elif cday=='Tuesday': 144 embed = DiscordEmbed(title=phy, description=des, color='33ff00')145 embed.set_author(name='Physics')146 embed.set_footer(text='footer here')147 embed.set_timestamp()148 webhook.add_embed(embed)149 webhook.execute()150 time.sleep(1800)151 continue;152 elif cday=='Wednesday': 153 embed = DiscordEmbed(title=eng, description=des, color='33ff00')154 embed.set_author(name='English')155 embed.set_footer(text='footer here')156 embed.set_timestamp()157 webhook.add_embed(embed)158 webhook.execute()159 time.sleep(1800)160 continue;161 elif cday=='Thursday':162 embed = DiscordEmbed(title=eng, description=des, color='33ff00')163 embed.set_author(name='English')164 embed.set_footer(text='footer here')165 embed.set_timestamp()166 webhook.add_embed(embed)167 webhook.execute()168 time.sleep(1800)169 continue;170 elif cday=='Friday':171 embed = DiscordEmbed(title=psp, description=des, color='33ff00')172 embed.set_author(name='PSP')173 embed.set_footer(text='footer here')174 embed.set_timestamp()175 webhook.add_embed(embed)176 webhook.execute()177 time.sleep(1800)178 continue;179 elif cday == 'Saturday':180 embed = DiscordEmbed(title=phy, description=des, color='33ff00')181 embed.set_author(name='Physics')182 embed.set_footer(text='footer here')183 embed.set_timestamp()184 webhook.add_embed(embed)185 webhook.execute()186 time.sleep(1800)187 continue; 188 else:189 print("Holiday :)")190 time.sleep(21600)191192 elif ctime == "13:25:00": #4th hour193 print("4th class")194 if cday=='Monday': 195 embed = DiscordEmbed(title=beee, description=des, color='33ff00')196 embed.set_author(name='BEEE')197 embed.set_footer(text='footer here')198 embed.set_timestamp()199 webhook.add_embed(embed)200 webhook.execute()201 time.sleep(1800)202 continue;203 elif cday=='Tuesday': 204 embed = DiscordEmbed(title=mde, description=des, color='33ff00')205 embed.set_author(name='Maths')206 embed.set_footer(text='footer here')207 embed.set_timestamp()208 webhook.add_embed(embed)209 webhook.execute()210 time.sleep(1800)211 continue;212 elif cday=='Wednesday': 213 embed = DiscordEmbed(title=che, description=des, color='33ff00')214 embed.set_author(name='Chemistry')215 embed.set_footer(text='footer here')216 embed.set_timestamp()217 webhook.add_embed(embed)218 webhook.execute()219 time.sleep(1800)220 continue;221 elif cday=='Thursday':222 embed = DiscordEmbed(title=psp, description=des, color='33ff00')223 embed.set_author(name='PSP')224 embed.set_footer(text='footer here')225 embed.set_timestamp()226 webhook.add_embed(embed)227 webhook.execute()228 time.sleep(1800)229 continue;230 elif cday=='Friday':231 embed = DiscordEmbed(title=beee, description=des, color='33ff00')232 embed.set_author(name='BEEE')233 embed.set_footer(text='footer here')234 embed.set_timestamp()235 webhook.add_embed(embed)236 webhook.execute()237 time.sleep(1800)238 continue;239 elif cday == 'Saturday':240 embed = DiscordEmbed(title=mde, description=des, color='33ff00')241 embed.set_author(name='Maths')242 embed.set_footer(text='footer here')243 embed.set_timestamp()244 webhook.add_embed(embed)245 webhook.execute()246 time.sleep(1800)247 continue; 248 else:249 print("Holiday :)")250 time.sleep(21600)251252 elif ctime == "14:20:00": #5th hr253 print("5th class")254 if cday=='Monday': 255 embed = DiscordEmbed(title=phy, description=des, color='33ff00')256 embed.set_author(name='Physics')257 embed.set_footer(text='footer here')258 embed.set_timestamp()259 webhook.add_embed(embed)260 webhook.execute()261 time.sleep(1800)262 continue;263 elif cday=='Tuesday': 264 embed = DiscordEmbed(title=che, description=des, color='33ff00')265 embed.set_author(name='Chemistry')266 embed.set_footer(text='footer here')267 embed.set_timestamp()268 webhook.add_embed(embed)269 webhook.execute()270 time.sleep(1800)271 continue;272 elif cday=='Wednesday': 273 embed = DiscordEmbed(title=beee, description=des, color='33ff00')274 embed.set_author(name='BEEE')275 embed.set_footer(text='footer here')276 embed.set_timestamp()277 webhook.add_embed(embed)278 webhook.execute()279 time.sleep(1800)280 continue;281 elif cday=='Thursday':282 embed = DiscordEmbed(title=psp, description=des, color='33ff00')283 embed.set_author(name='PSP')284 embed.set_footer(text='footer here')285 embed.set_timestamp()286 webhook.add_embed(embed)287 webhook.execute()288 time.sleep(1800)289 continue;290 elif cday=='Friday':291 embed = DiscordEmbed(title=eng, description=des, color='33ff00')292 embed.set_author(name='English')293 embed.set_footer(text='footer here')294 embed.set_timestamp()295 webhook.add_embed(embed)296 webhook.execute()297 time.sleep(1800)298 continue;299 elif cday == 'Saturday':300 embed = DiscordEmbed(title=eng, description=des, color='33ff00')301 embed.set_author(name='English')302 embed.set_footer(text='footer here')303 embed.set_timestamp()304 webhook.add_embed(embed)305 webhook.execute()306 time.sleep(1800)307 continue; 308 else:309 print("Holiday :)")310 time.sleep(21600)311312 else:313 #print(ctime)
...
test_sasclient_marker.py
Source:test_sasclient_marker.py
...48 Test the serialisation of Markers. We test against recorded byte strings that we know to be49 correct.50 """51 def test_empty(self):52 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)53 self.assertEqual(marker.serialize(), MARKER_STRING_EMPTY)54 def test_one_static_param(self):55 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)56 marker.add_static_param(333)57 self.assertEqual(marker.serialize(), MARKER_STRING_ONE_STATIC)58 def test_two_static_params(self):59 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)60 marker.add_static_params([333, 444])61 self.assertEqual(marker.serialize(), MARKER_STRING_TWO_STATIC)62 def test_one_variable_param(self):63 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)64 marker.add_variable_param("test parameter")65 self.assertEqual(marker.serialize(), MARKER_STRING_ONE_VAR)66 def test_two_variable_params(self):67 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)68 marker.add_variable_params(["test parameter", "other test parameter"])69 self.assertEqual(marker.serialize(), MARKER_STRING_TWO_VAR)70 # Now just check that __str__ doesn't throw71 self.assertGreater(len(str(marker)), 0)72 def test_params_no_list(self):73 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)74 with self.assertRaises(TypeError):75 marker.add_static_params(333)76 with self.assertRaises(TypeError):77 marker.add_variable_params("test parameter")78 def test_ordering(self):79 trail = Trail()80 marker_static_first = Marker(trail, 222).set_timestamp(TIMESTAMP)81 marker_static_first.add_static_params([333, 444])82 marker_static_first.add_variable_params(["test parameter", "other test parameter"])83 marker_static_first.set_instance_id(555)84 marker_variable_first = Marker(trail, 222).set_timestamp(TIMESTAMP)85 marker_variable_first.add_variable_params(["test parameter", "other test parameter"])86 marker_variable_first.set_instance_id(555)87 marker_variable_first.add_static_params([333, 444]).set_timestamp(TIMESTAMP)88 self.assertEqual(marker_static_first.serialize(), marker_variable_first.serialize())89 self.assertEqual(marker_static_first.serialize(), MARKER_STRING_ALL)90 def test_interfaces(self):91 trail = Trail()92 marker_constructor = Marker(93 trail,94 222,95 555,96 False,97 SCOPE_NONE,98 [333, 444],99 ["test parameter", "other test parameter"]).set_timestamp(TIMESTAMP)100 marker_plurals = Marker(trail, 222).set_timestamp(TIMESTAMP)101 marker_plurals.set_instance_id(555)102 marker_plurals.add_static_params([333, 444])103 marker_plurals.add_variable_params(["test parameter", "other test parameter"])104 marker_singles = Marker(trail, 222).set_timestamp(TIMESTAMP)105 marker_singles.set_instance_id(555)106 marker_singles.add_static_param(333).add_static_param(444)107 marker_singles.add_variable_param("test parameter")\108 .add_variable_param("other test parameter")109 self.assertEqual(marker_constructor.serialize(), marker_plurals.serialize())110 self.assertEqual(marker_constructor.serialize(), marker_singles.serialize())111 self.assertEqual(marker_constructor.serialize(), MARKER_STRING_ALL)112 def test_scope_branch(self):113 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)114 marker.set_association_scope(SCOPE_BRANCH)115 self.assertEqual(marker.serialize(), MARKER_STRING_BRANCH)116 pass117 def test_scope_trace(self):118 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)119 marker.set_association_scope(SCOPE_TRACE)120 self.assertEqual(marker.serialize(), MARKER_STRING_TRACE)121 pass122 def test_reactivate(self):123 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)124 marker.set_association_scope(SCOPE_BRANCH).set_reactivate(False)125 self.assertEqual(marker.serialize(), MARKER_STRING_REACTIVATE)126 pass127 def test_reactivate_scope_none(self):128 marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)129 marker.set_reactivate(False)130 self.assertEqual(marker.serialize(), MARKER_STRING_EMPTY)...
test_sasclient_event.py
Source:test_sasclient_event.py
...34 Test the serialisation of Events. We test against recorded byte strings that we know to be35 correct.36 """37 def test_empty(self):38 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)39 self.assertEqual(event.serialize(), EVENT_STRING_EMPTY)40 def test_one_static_param(self):41 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)42 event.add_static_param(333)43 self.assertEqual(event.serialize(), EVENT_STRING_ONE_STATIC)44 def test_two_static_params(self):45 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)46 event.add_static_params([333, 444])47 self.assertEqual(event.serialize(), EVENT_STRING_TWO_STATIC)48 def test_one_variable_param(self):49 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)50 event.add_variable_param("test parameter")51 self.assertEqual(event.serialize(), EVENT_STRING_ONE_VAR)52 def test_two_variable_params(self):53 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)54 event.add_variable_params(["test parameter", "other test parameter"])55 self.assertEqual(event.serialize(), EVENT_STRING_TWO_VAR)56 # Now just check that __str__ doesn't throw57 self.assertGreater(len(str(event)), 0)58 def test_compressed_variable_param(self):59 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)60 event.add_variable_param("test parameter", compress=COMPRESS_ZLIB)61 self.assertEqual(event.serialize(), EVENT_STRING_COMPRESSED_VAR)62 def test_unknown_compression(self):63 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)64 with self.assertRaises(ValueError):65 event.add_variable_param("test parameter", compress='bogus_compression')66 def test_params_no_list(self):67 event = Event(Trail(), 222).set_timestamp(TIMESTAMP)68 with self.assertRaises(TypeError):69 event.add_static_params(333)70 with self.assertRaises(TypeError):71 event.add_variable_params("test parameter")72 def test_ordering(self):73 trail = Trail()74 event_static_first = Event(trail, 222).set_timestamp(TIMESTAMP)75 event_static_first.add_static_params([333, 444])76 event_static_first.add_variable_params(["test parameter", "other test parameter"])77 event_static_first.set_instance_id(555)78 event_variable_first = Event(trail, 222).set_timestamp(TIMESTAMP)79 event_variable_first.add_variable_params(["test parameter", "other test parameter"])80 event_variable_first.set_instance_id(555)81 event_variable_first.add_static_params([333, 444]).set_timestamp(TIMESTAMP)82 self.assertEqual(event_static_first.serialize(), event_variable_first.serialize())83 self.assertEqual(event_static_first.serialize(), EVENT_STRING_ALL)84 def test_interfaces(self):85 trail = Trail()86 event_constructor = Event(87 trail,88 222,89 555,90 [333, 444],91 ["test parameter", "other test parameter"]).set_timestamp(TIMESTAMP)92 event_plurals = Event(trail, 222).set_timestamp(TIMESTAMP)93 event_plurals.set_instance_id(555)94 event_plurals.add_static_params([333, 444])95 event_plurals.add_variable_params(["test parameter", "other test parameter"])96 event_singles = Event(trail, 222).set_timestamp(TIMESTAMP)97 event_singles.set_instance_id(555)98 event_singles.add_static_param(333).add_static_param(444)99 event_singles.add_variable_param("test parameter")\100 .add_variable_param("other test parameter")101 self.assertEqual(event_constructor.serialize(), event_plurals.serialize())102 self.assertEqual(event_constructor.serialize(), event_singles.serialize())...
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!!