Best Python code snippet using localstack_python
models.py
Source:models.py
1#!/usr/bin/env python2from django.db import models3import json4def is_none_or_empty(str):5 """6 Checks if a string is None or empty string.7 """8 return not str9class Config(models.Model):10 # Social widgets11 instagram_widget_url = models.TextField()12 twitter_widget_id = models.TextField()13 # Calendar14 gcal_api_key = models.TextField(null=True, blank=True)15 gcal_dnollk_calendar_id = models.TextField(null=True, blank=True)16 gcal_dnollk_calendar_url = models.TextField(null=True, blank=True)17 gcal_timeedit_calendar_id = models.TextField(null=True, blank=True)18 gcal_asp_calendar_id = models.TextField(null=True, blank=True)19 # Form20 gform_link = models.TextField(null=True, blank=True)21 gform_embed_link = models.TextField(null=True, blank=True)22 enable_form = models.BooleanField()23 # Logos and headers24 logo_url = models.TextField(default="/static/dnollkse/images/logo.png")25 header_url = models.TextField(default="/static/dnollkse/images/header.jpg")26 favicon_url = models.TextField(null=True, blank=True)27 year = models.CharField(max_length=4, default="2017")28 def is_dnollk_calendar_enabled(self):29 """30 Returns whether the dnollk calendar is enabled31 """32 return not is_none_or_empty(self.gcal_api_key) \33 and not is_none_or_empty(self.gcal_dnollk_calendar_id) \34 and not is_none_or_empty(self.gcal_dnollk_calendar_url)35 def is_timeedit_calendar_enabled(self):36 """37 Returns whether the timeedit (school) calendar is enabled38 """39 return not is_none_or_empty(self.gcal_api_key) \40 and not is_none_or_empty(self.gcal_timeedit_calendar_id)41 def is_asp_calendar_enabled(self):42 """43 Returns whether the asp calendar is enabled44 """45 return not is_none_or_empty(self.gcal_api_key) \46 and not is_none_or_empty(self.gcal_asp_calendar_id)47 def calEventSources(self):48 """49 Returns a python object with the event sources used in FullCalender.50 """51 eventSources = []52 if self.is_dnollk_calendar_enabled:53 eventSources.append({54 'googleCalendarId': self.gcal_dnollk_calendar_id,55 'className': 'eventCalendar',56 'color': "#FA6607"57 })58 if self.is_timeedit_calendar_enabled:59 eventSources.append({60 'googleCalendarId': self.gcal_timeedit_calendar_id,...
Validator.py
Source:Validator.py
2class Validator:3 @staticmethod4 def validate_signup(username: str, password: str):5 errors = []6 if is_none_or_empty(username):7 errors.append("username cannot be blank")8 if is_none_or_empty(password):9 errors.append("password cannot be blank")10 if len(errors):11 raise ValidationException(errors)12 @staticmethod13 def validate_login(username: str, password: str):14 errors = []15 if is_none_or_empty(username):16 errors.append("username cannot be blank")17 if is_none_or_empty(password):18 errors.append("password cannot be blank")19 if len(errors):20 raise ValidationException(errors)21def is_none_or_empty(var) -> bool:...
model_emailmessage.py
Source:model_emailmessage.py
...9 __table__ = Table('McEmailMessage', Model.metadata,10 autoload=True,11 autoload_with=Model.engine)12 @staticmethod13 def is_none_or_empty(s):14 return (s is not None) and (len(s) > 0)15 @querable16 def is_read(self):17 return self.IsRead18 @querable19 def has_to_addresses(self):20 return McEmailMessage.is_none_or_empty(self.To)21 @querable22 def has_cc_addresses(self):23 return McEmailMessage.is_none_or_empty(self.Cc)24 @querable25 def has_subject(self):...
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!!