Best Python code snippet using localstack_python
test_schema.py
Source: test_schema.py
...3import numpy as np4from aodntools.ncwriter.schema import (validate_template, validate_dimensions, validate_variables,5 validate_global_attributes, ValidationError)6class TestSchema(unittest.TestCase):7 def test_validate_template(self):8 validate_template({})9 validate_template({'_dimensions': {'X': 1}})10 validate_template({'_variables': {'X': {'name': 'X'}}})11 validate_template({'title': 'test'})12 self.assertRaises(ValidationError, validate_template, {'_bad': 1})13 self.assertRaises(ValidationError, validate_template, {'_dimensions': None})14 self.assertRaises(ValidationError, validate_template, {'_variables': 1})15 self.assertRaises(ValidationError, validate_template, {'_variables': {'X': {'_dimensions': 1}}})16 def test_validate_dimensions(self):17 validate_dimensions({})18 validate_dimensions({'X': 1, 'Y': None})19 with self.assertRaises(ValidationError):20 validate_dimensions(None)21 with self.assertRaises(ValidationError):22 validate_dimensions('X')23 with self.assertRaises(ValidationError):24 validate_dimensions(['X'])25 with self.assertRaises(ValidationError):...
forms.py
Source: forms.py
...25 if data:26 self.show_preview = 'show_preview' in data27 self.send_preview = 'send_preview' in data28 super(CommunicationEventTypeForm, self).__init__(data, *args, **kwargs)29 def validate_template(self, value):30 try:31 Template(value)32 except TemplateSyntaxError as e:33 raise forms.ValidationError(six.text_type(e))34 def clean_email_subject_template(self):35 subject = self.cleaned_data['email_subject_template']36 self.validate_template(subject)37 return subject38 def clean_email_body_template(self):39 body = self.cleaned_data['email_body_template']40 self.validate_template(body)41 return body42 def clean_email_body_html_template(self):43 body = self.cleaned_data['email_body_html_template']44 self.validate_template(body)45 return body46 def clean_preview_order_number(self):47 number = self.cleaned_data['preview_order_number'].strip()48 if not self.instance.is_order_related():49 return number50 if not self.show_preview and not self.send_preview:51 return number52 try:53 self.preview_order = Order.objects.get(number=number)54 except Order.DoesNotExist:55 raise forms.ValidationError(_(56 "No order found with this number"))57 return number58 def clean_preview_email(self):...
test_template_validation.py
Source: test_template_validation.py
...10 subject='{{ foo }}',11 body='{{ bar }}'12 )13 try:14 validate_template(template)15 except ValidationError:16 pytest.fail("Unexpected validationError")17 def test_template_syntax_error(self):18 template = MailTemplate(19 template_type='template',20 subject='{{ foo bar }}',21 body='{{ bar }}'22 )23 with pytest.raises(ValidationError) as excinfo:24 validate_template(template)25 self.assertEqual(excinfo.value.code, 'syntax_error')26 def test_template_invalid_error(self):27 template = MailTemplate(28 template_type='template',29 subject='{{ bar }}',30 body='{{ bar }}'31 )32 template.CONFIG["template"]["subject"][0].required = True33 with pytest.raises(ValidationError) as excinfo:34 validate_template(template)35 self.assertEqual(excinfo.value.message, 'These variables are required, but missing: {{ foo }}')36 def test_valid_template_with_attribute(self):37 template = MailTemplate(38 template_type='template',39 subject='{{ foo.bar }}',40 body='{{ bar.foo }}'41 )42 try:43 validate_template(template)44 except ValidationError:45 pytest.fail("Unexpected validationError")46 def test_valid_template_with_attribute_required_variable(self):47 template = MailTemplate(48 template_type='template',49 subject='{{ foo.bar }}',50 body='{{ bar.foo }}'51 )52 # Make foo required53 template.CONFIG["template"]["subject"][0].required = True54 try:55 validate_template(template)56 except ValidationError:57 pytest.fail("Unexpected validationError")58 def test_valid_template_with_unknown_variable(self):59 template = MailTemplate(60 template_type='template',61 subject='{{ foobar }}',62 body='{{ bar }}'63 )64 try:65 validate_template(template)66 except ValidationError:...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!