From 9f629ff62c270fd3771c381f78aa36f473e65bb5 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Fri, 10 Aug 2018 17:04:14 +0800 Subject: Added the logic to validate HPA Added the code logic to validate HPA for opnfv tosca parser. Also corrected some hpa validation schema errors introduced by the previous patch. Change-Id: Icd61d34d7915aa965ec32adfc3c0f1a117dd6f3e Issue-ID: VNFSDK-194 Signed-off-by: Lianhao Lu --- tests/validator/test_toscaparser_validator.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/validator') diff --git a/tests/validator/test_toscaparser_validator.py b/tests/validator/test_toscaparser_validator.py index c35d1ed..3348d60 100644 --- a/tests/validator/test_toscaparser_validator.py +++ b/tests/validator/test_toscaparser_validator.py @@ -15,13 +15,29 @@ import os +import pytest + from vnfsdk_pkgtools.packager import csar from vnfsdk_pkgtools.validator import toscaparser_validator CSAR_PATH = 'tests/resources/test_import.csar' +HPA_PATH = 'tests/resources/hpa.csar' +BAD_HPA_PATH = 'tests/resources/hpa_bad.csar' def test_validate(tmpdir): reader = csar._CSARReader(CSAR_PATH, str(tmpdir.mkdir('validate'))) validator = toscaparser_validator.ToscaparserValidator() validator.validate(reader) assert hasattr(validator, 'tosca') + +def test_validate_hpa(tmpdir): + reader = csar._CSARReader(HPA_PATH, str(tmpdir.mkdir('validate'))) + validator = toscaparser_validator.ToscaparserValidator() + validator.validate(reader) + assert hasattr(validator, 'tosca') + +def test_validate_hpa_bad(tmpdir): + reader = csar._CSARReader(BAD_HPA_PATH, str(tmpdir.mkdir('validate'))) + validator = toscaparser_validator.ToscaparserValidator() + with pytest.raises(toscaparser_validator.HpaValueError): + validator.validate(reader) -- cgit 1.2.3-korg