Best Python code snippet using tempest_python
order.py
Source:order.py
...9 """Base order validator class, that runs before validator schema"""10 order_data: dict11 def validate_data(self) -> dict:12 """Main validator."""13 self._validate_datetime_format()14 return self.order_data15 def _validate_datetime_format(self) -> NoReturn:16 """17 Datetime format validator.18 Checks datetime formats for compliance available formats.19 """20 start: str | dt = self.order_data.get('start_datetime')21 end: str | dt = self.order_data.get('end_datetime')22 available_formats = ['%Y-%m-%dT%H:%M', "%Y-%m-%d"]23 if start and end:24 for dt_format in available_formats:25 if self._convert_start_end_to_dt_format(start, end, dt_format):26 return True27 raise JSONException(status_code=status.HTTP_400_BAD_REQUEST,28 message="Unsupported datetime format, should be '%Y-%m-%dT%H:%M' "29 "for 'get', 'put' or 'post' operations or "...
jsonschema_validator.py
Source:jsonschema_validator.py
...24# ISO 8601 which is defined in oslo_utils.timeutils25# so this checker will validate the date-time as defined in26# oslo_utils.timeutils27@FORMAT_CHECKER.checks('iso8601-date-time')28def _validate_datetime_format(instance):29 try:30 if isinstance(instance, jsonschema.compat.str_types):31 timeutils.parse_isotime(instance)32 except ValueError:33 return False34 else:...
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!!