Best Python code snippet using localstack_python
test_validator.py
Source:test_validator.py
1import os.path2import pytest3from unittest import TestCase4from samtranslator.yaml_helper import yaml_parse5from samtranslator.validator.validator import SamTemplateValidator6BASE_PATH = os.path.dirname(__file__)7INPUT_FOLDER = os.path.join(BASE_PATH, os.pardir, 'input')8@pytest.mark.parametrize('testcase', [9 'basic_function',10 'cloudwatchevent',11 'cloudwatch_logs_with_ref',12 'cloudwatchlog',13 'streams',14 'sqs',15 'simpletable',16 'simpletable_with_sse',17 'implicit_api',18 'explicit_api',19 'api_endpoint_configuration',20 'api_with_method_settings',21 'api_with_binary_media_types',22 'api_with_resource_refs',23 'api_with_cors',24 'api_with_cors_and_only_methods',25 'api_with_cors_and_only_headers',26 'api_with_cors_and_only_origins',27 'api_with_cors_and_only_maxage',28 'api_cache',29 's3',30 's3_create_remove',31 's3_existing_lambda_notification_configuration',32 's3_existing_other_notification_configuration',33 's3_filter',34 's3_multiple_events_same_bucket',35 's3_multiple_functions',36 'sns',37 'sns_existing_other_subscription',38 'sns_topic_outside_template',39 'alexa_skill',40 'iot_rule',41 'function_managed_inline_policy',42 'unsupported_resources',43 'intrinsic_functions',44 'basic_function_with_tags',45 'depends_on',46 'function_with_dlq',47 'function_with_kmskeyarn',48 'function_with_alias',49 'function_with_alias_intrinsics',50 'function_with_disabled_deployment_preference',51 'function_with_deployment_preference',52 'function_with_deployment_preference_all_parameters',53 'function_with_deployment_preference_multiple_combinations',54 'function_with_alias_and_event_sources',55 'function_with_resource_refs',56 'function_with_deployment_and_custom_role',57 'function_with_deployment_no_service_role',58 'function_with_policy_templates',59 'globals_for_function',60 'globals_for_api',61 'globals_for_simpletable',62 'all_policy_templates',63 'simple_table_ref_parameter_intrinsic',64 'simple_table_with_table_name',65 'function_concurrency',66 'simple_table_with_extra_tags',67 'explicit_api_with_invalid_events_config'68])69def test_validate_template_success(testcase):70 # These templates are failing validation, will fix schema one at a time71 excluded = [72 'api_endpoint_configuration',73 'api_with_binary_media_types',74 'api_with_cors',75 'cloudwatch_logs_with_ref',76 'sns',77 'sns_existing_other_subscription',78 'sns_topic_outside_template',79 'alexa_skill',80 'iot_rule',81 'function_managed_inline_policy',82 'unsupported_resources',83 'intrinsic_functions',84 'basic_function_with_tags',85 'function_with_kmskeyarn',86 'function_with_alias',87 'function_with_alias_intrinsics',88 'function_with_disabled_deployment_preference',89 'function_with_deployment_preference',90 'function_with_deployment_preference_all_parameters',91 'function_with_deployment_preference_multiple_combinations',92 'function_with_alias_and_event_sources',93 'function_with_resource_refs',94 'function_with_policy_templates',95 'globals_for_function',96 'all_policy_templates',97 'simple_table_ref_parameter_intrinsic',98 'simple_table_with_table_name',99 'function_concurrency',100 'simple_table_with_extra_tags'101 ]102 if testcase in excluded:103 return104 manifest = yaml_parse(open(os.path.join(INPUT_FOLDER, testcase + '.yaml'), 'r'))105 validation_errors = SamTemplateValidator.validate(manifest)106 has_errors = len(validation_errors)107 if has_errors:108 print("\nFailing template: {0}\n".format(testcase))109 print(validation_errors)...
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!!