Best Python code snippet using lisa_python
models.py
Source:models.py
...47 class Meta:48 ordering = ["-date_created", ]49 def __str__(self):50 return self.name51 def validate_started(self):52 time_now = timezone.now()53 start_date = self.start_date54 started = self.started55 if (time_now < start_date) and (started == True):56 raise ValidationError("Time did not reach upto the point to start")57 def validate_days(self):58 days = self.days59 if days is None:60 return None61 days = list(days)62 for i in days:63 if i not in DAYS_LIST:64 raise ValidationError("This should be a day Word")65 return True 66 def save(self, *args, **kwargs):67 if self.started and self.start_date:68 self.validate_days()69 self.validate_started()70 return super().save(*args, **kwargs)71 72class BatchImportantAnouncement(BaseModel):73 batch = models.ForeignKey(Batch, on_delete=models.SET_NULL, null=True)74 anouncement = models.TextField()75 end_date = models.DateTimeField(null=True)76 def __str__(self):77 return f"{self.batch} --> {self.anouncement}"78 def save(self, *args, **kwargs):79 end_date = self.end_date80 if not end_date:81 self.end_date = timezone.now() + timedelta(days=1)82 return super().save(*args, **kwargs)83class BatchUser(BaseModel):...
action.py
Source:action.py
...43 self.__is_started = True44 self.status = ActionStatus.RUNNING45 @abstractmethod46 async def stop(self) -> None:47 self.validate_started()48 @abstractmethod49 async def close(self) -> None:50 self.validate_started()51 @property52 def status(self) -> ActionStatus:53 """The Action's current state, for example, 'UNINITIALIZED'."""54 return self.__status55 @status.setter56 def status(self, value: ActionStatus) -> None:57 if self.__status != value:58 self._log.debug(59 f"{self.name} status changed from {self.__status.name} "60 f"to {value.name} with {self.__timer}"61 )62 self.__total += self.__timer.elapsed()63 message = ActionMessage(64 elapsed=self.__timer.elapsed(),65 sub_type=self.name,66 status=value,67 total_elapsed=self.__total,68 )69 notifier.notify(message=message)70 self.__timer = create_timer()71 self.__status = value72 def validate_started(self) -> None:73 if not self.__is_started:...
validate.py
Source:validate.py
1import i18n2import sys3import rdftools4def main():5 (LOG, cmd) = rdftools.startup('RDF file validator.', add_args=None)6 for input in cmd.input:7 LOG.info(i18n.t('scripts.validate_started', name=input))8 try:9 rdftools.read(input, cmd.read)10 LOG.info(i18n.t('scripts.validate_succeeded'))11 except: # noqa: E72212 LOG.warning(i18n.t('scripts.validate_failed', exc_info=True))...
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!!