Best Python code snippet using stestr_python
dm.py
Source:dm.py
1import random2from spambot import *3from spambot.helpers.gspam import GSPAM4from spambot.helpers.plinks import PLINKS5from telethon import events67myraid = False8myspam = False9a = False1011@MafiaBot1.on(events.NewMessage(outgoing=True, pattern='/dmraid'))12@MafiaBot2.on(events.NewMessage(outgoing=True, pattern='/dmraid'))13@MafiaBot3.on(events.NewMessage(outgoing=True, pattern='/dmraid'))14@MafiaBot4.on(events.NewMessage(outgoing=True, pattern='/dmraid'))15@MafiaBot5.on(events.NewMessage(outgoing=True, pattern='/dmraid'))16@MafiaBot1.on(events.NewMessage(incoming=True, pattern='/dmraid'))17@MafiaBot2.on(events.NewMessage(incoming=True, pattern='/dmraid'))18@MafiaBot3.on(events.NewMessage(incoming=True, pattern='/dmraid'))19@MafiaBot4.on(events.NewMessage(incoming=True, pattern='/dmraid'))20@MafiaBot5.on(events.NewMessage(incoming=True, pattern='/dmraid'))21async def dmraid(e):22 if e.sender_id in MY_USERS:23 await e.delete()24 name = e.sender.first_name25 user_id = e.sender_id26 mention = f"[{name}](tg://user?id={user_id})"27 me = await e.client.get_me()28 global myraid29 if e.is_reply is True:30 replied = await e.get_reply_message()31 get_name = replied.sender.first_name32 get_id = replied.sender.id33 tag = f"[{get_name}](tg://user?id={get_id})"34 try:35 if get_id in GOD_USERS:36 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Kid!` {tag} `Is You're Daddy! You Cant Abuse Him!`")37 elif get_id in DEV_USERS:38 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Dev User!`")39 elif get_id == OWNER_ID:40 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Master!`")41 elif get_id in CO_OWNER_ID:42 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Co-Owner!`")43 elif get_id in SUDO_USERS:44 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Sudo User!`")45 elif get_id == me.id:46 await e.client.send_message(e.chat_id, "`I'm Not Going To Take Action's on Myself!`")47 else:48 await e.client.send_message(e.chat_id, f"`Dm Raid Activated On` {tag}!")49 myraid = True50 while myraid == True:51 myMessage = random.choice(GSPAM)52 await e.client.send_message(get_id, f"{myMessage}")53 except Exception as er:54 print(er)55 await e.client.send_message(e.chat_id, "Something Went Wrong!")56 else:57 text = e.raw_text[8:]58 try:59 if text == "":60 await e.client.send_message(e.chat_id, "Please Mention Someone To Activate Dm Raid!")61 else:62 entity = await e.client.get_entity(text)63 get_name = entity.first_name64 get_id = entity.id65 tag = f"[{get_name}](tg://user?id={get_id})"66 if get_id in GOD_USERS:67 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Kid!` {tag} `Is You're Daddy! You Cant Abuse Him!`")68 elif get_id in DEV_USERS:69 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Dev User!`")70 elif get_id == OWNER_ID:71 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Master!`")72 elif get_id in CO_OWNER_ID:73 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Co-Owner!`")74 elif get_id in SUDO_USERS:75 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Sudo User!`")76 elif get_id == me.id:77 await e.client.send_message(e.chat_id, "`I'm Not Going To Take Action's on Myself!`")78 else:79 await e.client.send_message(e.chat_id, f"`Dm Raid Activated On` {tag}!")80 myraid = True81 while myraid == True:82 myMessage = random.choice(GSPAM)83 await e.client.send_message(get_id, f"{myMessage}")84 except Exception as er:85 print(er)86 await e.client.send_message(e.chat_id, "Something Went Wrong!")8788@MafiaBot1.on(events.NewMessage(outgoing=True, pattern='/sdmraid'))89@MafiaBot2.on(events.NewMessage(outgoing=True, pattern='/sdmraid'))90@MafiaBot3.on(events.NewMessage(outgoing=True, pattern='/sdmraid'))91@MafiaBot4.on(events.NewMessage(outgoing=True, pattern='/sdmraid'))92@MafiaBot5.on(events.NewMessage(outgoing=True, pattern='/sdmraid'))93@MafiaBot1.on(events.NewMessage(incoming=True, pattern='/sdmraid'))94@MafiaBot2.on(events.NewMessage(incoming=True, pattern='/sdmraid'))95@MafiaBot3.on(events.NewMessage(incoming=True, pattern='/sdmraid'))96@MafiaBot4.on(events.NewMessage(incoming=True, pattern='/sdmraid'))97@MafiaBot5.on(events.NewMessage(incoming=True, pattern='/sdmraid'))98async def sdmraid(e):99 if e.sender_id in MY_USERS:100 await e.delete()101 global myraid102 if e.is_reply is True:103 try:104 replied = await e.get_reply_message()105 get_name = replied.sender.first_name106 get_id = replied.sender.id107 tag = f"[{get_name}](tg://user?id={get_id})"108 myraid = False109 await e.client.send_message(e.chat_id, f"`Dm Raid Deactivated On` {tag}!")110 except Exception as er:111 print(er)112 await e.client.send_message(e.chat_id, "Something Went Wrong!")113 else:114 try:115 text = e.raw_text[9:]116 if text == "":117 await e.client.send_message(e.chat_id, "Please Mention Someone To Deactivate Dm Raid!")118 else:119 entity = await e.client.get_entity(text)120 get_name = entity.first_name121 get_id = entity.id122 tag = f"[{get_name}](tg://user?id={get_id})"123 myraid = False124 await e.client.send_message(e.chat_id, f"`Dm Raid Deactivated On` {tag}!")125 except Exception as er:126 print(er)127 await e.client.send_message(e.chat_id, "Something Went Wrong!")128129@MafiaBot1.on(events.NewMessage(outgoing=True, pattern='/dmspam'))130@MafiaBot2.on(events.NewMessage(outgoing=True, pattern='/dmspam'))131@MafiaBot3.on(events.NewMessage(outgoing=True, pattern='/dmspam'))132@MafiaBot4.on(events.NewMessage(outgoing=True, pattern='/dmspam'))133@MafiaBot5.on(events.NewMessage(outgoing=True, pattern='/dmspam'))134@MafiaBot1.on(events.NewMessage(incoming=True, pattern='/dmspam'))135@MafiaBot2.on(events.NewMessage(incoming=True, pattern='/dmspam'))136@MafiaBot3.on(events.NewMessage(incoming=True, pattern='/dmspam'))137@MafiaBot4.on(events.NewMessage(incoming=True, pattern='/dmspam'))138@MafiaBot5.on(events.NewMessage(incoming=True, pattern='/dmspam'))139async def dmspam(e):140 if e.sender_id in MY_USERS:141 await e.delete()142 name = e.sender.first_name143 user_id = e.sender_id144 mention = f"[{name}](tg://user?id={user_id})"145 me = await e.client.get_me()146 global myspam147 if e.is_reply is True:148 replied = await e.get_reply_message()149 replied_message = replied.message 150 text = e.raw_text[8:]151 try:152 if text == "":153 await e.client.send_message(e.chat_id, "Please Mention Someone To Activate Dm Spam!")154 else:155 entity = await e.client.get_entity(text)156 get_name = entity.first_name157 get_id = entity.id158 tag = f"[{get_name}](tg://user?id={get_id})"159 if get_id in GOD_USERS:160 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Kid!` {tag} `Is You're Daddy! You Cant Abuse Him!`")161 elif get_id in DEV_USERS:162 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Dev User!`")163 elif get_id == OWNER_ID:164 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Master!`")165 elif get_id in CO_OWNER_ID:166 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Co-Owner!`")167 elif get_id in SUDO_USERS:168 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Sudo User!`")169 elif get_id == me.id:170 await e.client.send_message(e.chat_id, "`I'm Not Going To Take Action's on Myself!`")171 else:172 await e.client.send_message(e.chat_id, f"`Dm Spam Activated On` {tag}!")173 myspam = True174 while myspam == True:175 await e.client.send_message(get_id, f"{replied_message}")176 except Exception as er:177 print(er)178 await e.client.send_message(e.chat_id, "Something Went Wrong!")179180@MafiaBot1.on(events.NewMessage(outgoing=True, pattern='/sdmspam'))181@MafiaBot2.on(events.NewMessage(outgoing=True, pattern='/sdmspam'))182@MafiaBot3.on(events.NewMessage(outgoing=True, pattern='/sdmspam'))183@MafiaBot4.on(events.NewMessage(outgoing=True, pattern='/sdmspam'))184@MafiaBot5.on(events.NewMessage(outgoing=True, pattern='/sdmspam'))185@MafiaBot1.on(events.NewMessage(incoming=True, pattern='/sdmspam'))186@MafiaBot2.on(events.NewMessage(incoming=True, pattern='/sdmspam'))187@MafiaBot3.on(events.NewMessage(incoming=True, pattern='/sdmspam'))188@MafiaBot4.on(events.NewMessage(incoming=True, pattern='/sdmspam'))189@MafiaBot5.on(events.NewMessage(incoming=True, pattern='/sdmspam'))190async def sdmspam(e):191 if e.sender_id in MY_USERS:192 await e.delete()193 global myspam194 if e.is_reply is True:195 try:196 replied = await e.get_reply_message()197 get_name = replied.sender.first_name198 get_id = replied.sender.id199 tag = f"[{get_name}](tg://user?id={get_id})"200 myspam = False201 await e.client.send_message(e.chat_id, f"`Dm Spam Deactivated On` {tag}!")202 except Exception as er:203 print(er)204 await e.client.send_message(e.chat_id, "Something Went Wrong!")205 else:206 try:207 text = e.raw_text[9:]208 if text == "":209 await e.client.send_message(e.chat_id, "Please Mention Someone To Deactivate Dm Spam!")210 else:211 entity = await e.client.get_entity(text)212 get_name = entity.first_name213 get_id = entity.id214 tag = f"[{get_name}](tg://user?id={get_id})"215 myspam = False216 await e.client.send_message(e.chat_id, f"`Dm Spam Deactivated On` {tag}!")217 except Exception as er:218 print(er)219 await e.client.send_message(e.chat_id, "Something Went Wrong!")220221@MafiaBot1.on(events.NewMessage(outgoing=True, pattern='/dmpspam'))222@MafiaBot2.on(events.NewMessage(outgoing=True, pattern='/dmpspam'))223@MafiaBot3.on(events.NewMessage(outgoing=True, pattern='/dmpspam'))224@MafiaBot4.on(events.NewMessage(outgoing=True, pattern='/dmpspam'))225@MafiaBot5.on(events.NewMessage(outgoing=True, pattern='/dmpspam'))226@MafiaBot1.on(events.NewMessage(incoming=True, pattern='/dmpspam'))227@MafiaBot2.on(events.NewMessage(incoming=True, pattern='/dmpspam'))228@MafiaBot3.on(events.NewMessage(incoming=True, pattern='/dmpspam'))229@MafiaBot4.on(events.NewMessage(incoming=True, pattern='/dmpspam'))230@MafiaBot5.on(events.NewMessage(incoming=True, pattern='/dmpspam'))231async def dmpspam(e):232 if e.sender_id in MY_USERS:233 global a234 a = True235 await e.delete()236 name = e.sender.first_name237 user_id = e.sender_id238 mention = f"[{name}](tg://user?id={user_id})"239 me = await e.client.get_me()240 if e.is_reply == True:241 replied = await e.get_reply_message()242 replied_message = replied.message243 text = e.raw_text[9:]244 if text == "":245 await e.client.send_message(e.chat_id, "Please Mention Someone To Activate Porn Spam In Dm!")246 else:247 entity = await e.client.get_entity(text)248 get_name = entity.first_name249 get_id = entity.id250 tag = f"[{get_name}](tg://user?id={get_id})"251 if get_id in GOD_USERS:252 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Kid!` {tag} `Is You're Daddy! You Cant Abuse Him!`")253 elif get_id in DEV_USERS:254 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Dev User!`")255 elif get_id == OWNER_ID:256 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Master!`")257 elif get_id in CO_OWNER_ID:258 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Co-Owner!`")259 elif get_id in SUDO_USERS:260 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Sudo User!`")261 elif get_id == me.id:262 await e.client.send_message(e.chat_id, "`I'm Not Going To Take Action's on Myself!`")263 else:264 await e.client.send_message(e.chat_id, f"`Porn Spam In Dm Activated On` {tag}!") 265 try:266 while a == True:267 p = random.choice(PLINKS)268 await e.client.send_file(get_id, p, caption=replied_message)269 except Exception as er:270 print(er)271 await e.client.send_message(e.chat_id, "Something Went Wrong! Reply to a message or type a message to dmpspam!")272 else:273 text = e.raw_text[9:]274 if text == "":275 await e.client.send_message(e.chat_id, "Please Mention Someone To Activate Porn Spam In Dm!")276 else:277 entity = await e.client.get_entity(text)278 get_name = entity.first_name279 get_id = entity.id280 tag = f"[{get_name}](tg://user?id={get_id})"281 if get_id in GOD_USERS:282 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Kid!` {tag} `Is You're Daddy! You Cant Abuse Him!`")283 elif get_id in DEV_USERS:284 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Dev User!`")285 elif get_id == OWNER_ID:286 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Master!`")287 elif get_id in CO_OWNER_ID:288 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Co-Owner!`")289 elif get_id in SUDO_USERS:290 await e.client.send_message(e.chat_id, f"`Hey` {mention} `Nigga! I'm Not Going To Abuse My Sudo User!`")291 elif get_id == me.id:292 await e.client.send_message(e.chat_id, "`I'm Not Going To Take Action's on Myself!`")293 else:294 await e.client.send_message(e.chat_id, f"`Porn Spam In Dm Activated On` {tag}!") 295 try:296 while a == True:297 p = random.choice(PLINKS)298 await e.client.send_file(get_id, p)299 except Exception as er:300 print(er)301 await e.client.send_message(e.chat_id, "Something Went Wrong")302303304@MafiaBot1.on(events.NewMessage(outgoing=True, pattern="/dmpstop"))305@MafiaBot2.on(events.NewMessage(outgoing=True, pattern="/dmpstop"))306@MafiaBot3.on(events.NewMessage(outgoing=True, pattern="/dmpstop"))307@MafiaBot4.on(events.NewMessage(outgoing=True, pattern="/dmpstop"))308@MafiaBot5.on(events.NewMessage(outgoing=True, pattern="/dmpstop"))309@MafiaBot1.on(events.NewMessage(incoming=True, pattern="/dmpstop"))310@MafiaBot2.on(events.NewMessage(incoming=True, pattern="/dmpstop"))311@MafiaBot3.on(events.NewMessage(incoming=True, pattern="/dmpstop"))312@MafiaBot4.on(events.NewMessage(incoming=True, pattern="/dmpstop"))313@MafiaBot5.on(events.NewMessage(incoming=True, pattern="/dmpstop"))314async def dmpstop(e):315 if e.sender_id in MY_USERS:316 await e.delete()317 global a318 if e.is_reply is True:319 try:320 replied = await e.get_reply_message()321 get_name = replied.sender.first_name322 get_id = replied.sender.id323 tag = f"[{get_name}](tg://user?id={get_id})"324 a = False325 await e.client.send_message(e.chat_id, f"`Dm Porn Spam Deactivated On` {tag}!")326 except Exception as er:327 print(er)328 await e.client.send_message(e.chat_id, "Something Went Wrong!")329 else:330 try:331 text = e.raw_text[9:]332 if text == "":333 await e.client.send_message(e.chat_id, "Please Mention Someone To Deactivate Dm Porn Spam!")334 else:335 entity = await e.client.get_entity(text)336 get_name = entity.first_name337 get_id = entity.id338 tag = f"[{get_name}](tg://user?id={get_id})"339 a = False340 await e.client.send_message(e.chat_id, f"`Dm Porn Spam Deactivated On` {tag}!")341 except Exception as er:342 print(er)
...
test_recurring_shifts.py
Source:test_recurring_shifts.py
...19 start_day="tuesday",20 start_hour=8,21 start_minute=0,22 duration_minutes=300,23 user_id=self.worker.get_id())24 assert another_recurring_shift.get_id() > 025 assert another_recurring_shift.data.get("start_day") == "tuesday"26 # patch27 self.recurring_shift.patch(start_day="wednesday")28 assert self.recurring_shift.data.get("start_day") == "wednesday"29 self.other_recurring_shift.patch(start_day="wednesday")30 assert self.other_recurring_shift.data.get("start_day") == "wednesday"31 # delete32 another_recurring_shift.delete()33 with pytest.raises(Exception):34 self.role.get_recurring_shift(another_recurring_shift.get_id())35 def test_recurring_shifts_crud_admin(self):36 self.update_permission_admin()37 # get38 recurring_shifts = self.role.get_recurring_shifts()39 assert len(recurring_shifts) == 140 other_recurring_shifts = self.other_role.get_recurring_shifts()41 assert len(other_recurring_shifts) == 142 # post43 another_recurring_shift = self.role.create_recurring_shift(44 start_day="tuesday",45 start_hour=8,46 start_minute=0,47 duration_minutes=300,48 user_id=self.worker.get_id())49 assert another_recurring_shift.get_id() > 050 assert another_recurring_shift.data.get("start_day") == "tuesday"51 yet_another_recurring_shift = self.other_role.create_recurring_shift(52 start_day="tuesday",53 start_hour=8,54 start_minute=0,55 duration_minutes=300,56 user_id=self.other_worker.get_id())57 assert yet_another_recurring_shift.get_id() > 058 assert yet_another_recurring_shift.data.get("start_day") == "tuesday"59 # patch60 self.recurring_shift.patch(start_day="wednesday")61 assert self.recurring_shift.data.get("start_day") == "wednesday"62 self.other_recurring_shift.patch(start_day="wednesday")63 assert self.other_recurring_shift.data.get("start_day") == "wednesday"64 # delete65 another_recurring_shift.delete()66 with pytest.raises(Exception):67 self.role.get_recurring_shift(another_recurring_shift.get_id())68 yet_another_recurring_shift.delete()69 with pytest.raises(Exception):70 self.role.get_recurring_shift(yet_another_recurring_shift.get_id())71 def test_recurring_shifts_crud_manager(self):72 self.update_permission_manager()73 # get74 recurring_shifts = self.role.get_recurring_shifts()75 assert len(recurring_shifts) == 176 with pytest.raises(Exception):77 self.other_role.get_recurring_shifts()78 # post79 another_recurring_shift = self.role.create_recurring_shift(80 start_day="tuesday",81 start_hour=8,82 start_minute=0,83 duration_minutes=300,84 user_id=self.worker.get_id())85 assert another_recurring_shift.get_id() > 086 assert another_recurring_shift.data.get("start_day") == "tuesday"87 with pytest.raises(Exception):88 self.other_role.create_recurring_shift(89 start_day="tuesday",90 start_hour=8,91 start_minute=0,92 duration_minutes=300,93 user_id=self.other_worker.get_id())94 # patch95 self.recurring_shift.patch(start_day="wednesday")96 assert self.recurring_shift.data.get("start_day") == "wednesday"97 with pytest.raises(Exception):98 self.other_recurring_shift.patch(start_day="wednesday")99 # delete100 another_recurring_shift.delete()101 with pytest.raises(Exception):102 self.role.get_recurring_shift(another_recurring_shift.get_id())103 with pytest.raises(Exception):104 self.other_recurring_shift.delete()105 def test_recurring_shifts_crud_worker(self):106 self.update_permission_worker()107 # get108 recurring_shifts = self.role.get_recurring_shifts()109 assert len(recurring_shifts) == 1110 with pytest.raises(Exception):111 self.other_role.get_recurring_shifts()112 # post113 with pytest.raises(Exception):114 self.role.create_recurring_shift(115 start_day="tuesday",116 start_hour=8,117 start_minute=0,118 duration_minutes=300,119 user_id=self.worker.get_id())120 # patch121 with pytest.raises(Exception):122 self.recurring_shift.patch(start_day="wednesday")123 # delete124 with pytest.raises(Exception):...
test_forms.py
Source:test_forms.py
1from __future__ import unicode_literals2from django.test import TestCase3from dcim.forms import *4from dcim.models import *5def get_id(model, slug):6 return model.objects.get(slug=slug).id7class DeviceTestCase(TestCase):8 fixtures = ['dcim', 'ipam']9 def test_racked_device(self):10 test = DeviceForm(data={11 'name': 'test',12 'device_role': get_id(DeviceRole, 'leaf-switch'),13 'tenant': None,14 'manufacturer': get_id(Manufacturer, 'juniper'),15 'device_type': get_id(DeviceType, 'qfx5100-48s'),16 'site': get_id(Site, 'test1'),17 'rack': '1',18 'face': RACK_FACE_FRONT,19 'position': 41,20 'platform': get_id(Platform, 'juniper-junos'),21 'status': STATUS_ACTIVE,22 })23 self.assertTrue(test.is_valid(), test.fields['position'].choices)24 self.assertTrue(test.save())25 def test_racked_device_occupied(self):26 test = DeviceForm(data={27 'name': 'test',28 'device_role': get_id(DeviceRole, 'leaf-switch'),29 'tenant': None,30 'manufacturer': get_id(Manufacturer, 'juniper'),31 'device_type': get_id(DeviceType, 'qfx5100-48s'),32 'site': get_id(Site, 'test1'),33 'rack': '1',34 'face': RACK_FACE_FRONT,35 'position': 1,36 'platform': get_id(Platform, 'juniper-junos'),37 'status': STATUS_ACTIVE,38 })39 self.assertFalse(test.is_valid())40 def test_non_racked_device(self):41 test = DeviceForm(data={42 'name': 'test',43 'device_role': get_id(DeviceRole, 'pdu'),44 'tenant': None,45 'manufacturer': get_id(Manufacturer, 'servertech'),46 'device_type': get_id(DeviceType, 'cwg-24vym415c9'),47 'site': get_id(Site, 'test1'),48 'rack': '1',49 'face': None,50 'position': None,51 'platform': None,52 'status': STATUS_ACTIVE,53 })54 self.assertTrue(test.is_valid())55 self.assertTrue(test.save())56 def test_non_racked_device_with_face(self):57 test = DeviceForm(data={58 'name': 'test',59 'device_role': get_id(DeviceRole, 'pdu'),60 'tenant': None,61 'manufacturer': get_id(Manufacturer, 'servertech'),62 'device_type': get_id(DeviceType, 'cwg-24vym415c9'),63 'site': get_id(Site, 'test1'),64 'rack': '1',65 'face': RACK_FACE_REAR,66 'position': None,67 'platform': None,68 'status': STATUS_ACTIVE,69 })70 self.assertTrue(test.is_valid())...
fh4tracks.py
Source:fh4tracks.py
1from django import template2from overview.models import (FH4Track, FH4Championship, FH4Tune)3import util4register = template.Library()5@register.inclusion_tag('overview/overview_track.html', takes_context=True)6def fh4_all_tracks(context, url=""):7 """ Will display all FH4 Tracks (or one if 'id' is in querystring of URL. """8 get_options = util.get_GET_options(url)9 retVal = {10 'request': context['request'],11 }12 if "id" in get_options:13 try:14 GET_id = int(get_options['id']) - 115 except ValueError:16 GET_id = -117 else:18 GET_id = -119 if GET_id is not -1 and FH4Track.objects.all().count() > GET_id:20 retVal['events'] = [FH4Track.objects.all()[GET_id], ]21 else:22 retVal['events'] = context["events"]23 return retVal24@register.inclusion_tag('overview/overview_champ.html', takes_context=True)25def fh4_all_champs(context, url=''):26 """ Will display all FH4 championships (or one if 'id' is in querystring of URL). """27 get_options = util.get_GET_options(url)28 retVal = {29 'request': context['request'],30 }31 if "id" in get_options:32 try:33 GET_id = int(get_options['id']) - 134 except ValueError:35 GET_id = -136 else:37 GET_id = -138 if GET_id is not -1 and FH4Championship.objects.all().count() > GET_id:39 retVal['champs'] = [FH4Championship.objects.all()[GET_id], ]40 else:41 retVal['champs'] = context["champs"]42 return retVal43@register.inclusion_tag('overview/overview_tune.html', takes_context=True)44def fh4_all_tunes(context, url=''):45 """ Will display all FH4 setups (or one if 'id' is in querystring of URL). """46 get_options = util.get_GET_options(url)47 retVal = {48 'request': context['request'],49 }50 if "id" in get_options:51 try:52 GET_id = int(get_options['id']) - 153 except ValueError:54 GET_id = -155 else:56 GET_id = -157 if GET_id is not -1 and FH4Tune.objects.all().count() > GET_id:58 retVal['tunes'] = [FH4Tune.objects.all()[GET_id], ]59 else:60 retVal['tunes'] = context["tunes"]...
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!!