Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove soft template validation #2961

Merged
merged 3 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions samtranslator/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from samtranslator.plugins import LifeCycleEvents
from samtranslator.plugins.sam_plugins import SamPlugins
from samtranslator.public.sdk.template import SamTemplate
from samtranslator.validator.validator import SamTemplateValidator
from samtranslator.validator.value_validator import sam_expect

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -66,12 +65,3 @@ def _validate(self, sam_template, parameter_values): # type: ignore[no-untyped-
raise ValueError("`parameter_values` argument is required")

Parser.validate_datatypes(sam_template) # type: ignore[no-untyped-call]

try:
validator = SamTemplateValidator() # type: ignore[no-untyped-call]
validation_errors = validator.validate(sam_template) # type: ignore[no-untyped-call]
if validation_errors:
LOG.warning("Template schema validation reported the following errors: %s", validation_errors)
except Exception as e:
# Catching any exception and not re-raising to make sure any validation process won't break transform
LOG.exception("Exception from SamTemplateValidator: %s", e)
20 changes: 1 addition & 19 deletions tests/parser/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from unittest import TestCase
from unittest.mock import Mock, call, patch
from unittest.mock import Mock, call

from samtranslator.model.exceptions import InvalidDocumentException
from samtranslator.parser.parser import Parser
Expand All @@ -19,24 +19,6 @@ def test_parse(self):
parser._validate.assert_has_calls([call(sam_template, parameter_values)])
sam_plugins_mock.act.assert_has_calls([call(LifeCycleEvents.before_transform_template, sam_template)])

@patch("samtranslator.parser.parser.SamTemplateValidator")
@patch("samtranslator.parser.parser.LOG")
def test_validate_validator_failure(self, log_mock, sam_template_validator_class_mock):
exception = Exception()
sam_template_validator_class_mock.side_effect = exception
log_mock.exception = Mock()

sam_template = {
"Resources": {
"Function": {},
"Api": {},
}
}
paramerter_values = {"Param": "value"}
parser = Parser()
parser._validate(sam_template, paramerter_values)
log_mock.exception.assert_has_calls([call("Exception from SamTemplateValidator: %s", exception)])

def test_validate_parameter_values_is_required(self):
parser = Parser()
with self.assertRaises(ValueError):
Expand Down