diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2017-09-26 20:40:39 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2017-09-26 20:47:53 +0800 |
commit | 000ea52b78b072435f01d67dd799023117e67a2e (patch) | |
tree | 1f14cdb4485e2184904b553b82afd9e7139a18e5 /nfvparser/toscaparser/tests/test_toscatplvalidation.py | |
parent | 53065490134870ead778bff590cfd9e43ddd9f77 (diff) |
Sync code from nfv-toscaprser
Currently nfv-toscaparser has published the regular version of 0.5.1
the patch will synchronize the code.
JIRA: MODELING-23
Change-Id: If95579fc366b69b2b14b2e441ff9a3e6807e3820
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'nfvparser/toscaparser/tests/test_toscatplvalidation.py')
-rw-r--r-- | nfvparser/toscaparser/tests/test_toscatplvalidation.py | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/nfvparser/toscaparser/tests/test_toscatplvalidation.py b/nfvparser/toscaparser/tests/test_toscatplvalidation.py index 911867f..a8b1590 100644 --- a/nfvparser/toscaparser/tests/test_toscatplvalidation.py +++ b/nfvparser/toscaparser/tests/test_toscatplvalidation.py @@ -101,6 +101,7 @@ class ToscaTemplateValidationTest(TestCase): _('The template version "tosca_simple_yaml_1_10 in ' 'custom_types/imported_sample.yaml" is invalid. ' 'Valid versions are "tosca_simple_yaml_1_0, ' + 'tosca_simple_yaml_1_1, ' 'tosca_simple_profile_for_nfv_1_0_0".')) exception.ExceptionCollector.assertExceptionMessage( exception.UnknownFieldError, @@ -446,6 +447,18 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml self.assertTrue(custom_defs.get("mycompany.tosca.nodes." "WebApplication.WordPress")) + def test_imports_file_with_suffix_yml(self): + tpl_snippet = ''' + imports: + - custom_types/wordpress.yml + ''' + path = 'toscaparser/tests/data/tosca_elk.yaml' + custom_defs = self._imports_content_test(tpl_snippet, + path, + "node_types") + self.assertTrue(custom_defs.get("tosca.nodes." + "WebApplication.WordPress")) + def test_import_error_file_uri(self): tpl_snippet = ''' imports: @@ -1581,7 +1594,7 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml lambda: Policy(name, policies[name], None, None)) self.assertEqual(expectedmessage, err.__str__()) - def test_policy_trigger_valid_keyname(self): + def test_policy_trigger_valid_keyname_senlin_resources(self): tpl_snippet = ''' triggers: - resize_compute: @@ -1610,7 +1623,28 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml name = list(triggers.keys())[0] Triggers(name, triggers[name]) - def test_policy_trigger_invalid_keyname(self): + def test_policy_trigger_valid_keyname_heat_resources(self): + tpl_snippet = ''' + triggers: + - high_cpu_usage: + description: trigger + meter_name: cpu_util + condition: + constraint: utilization greater_than 60% + threshold: 60 + period: 600 + evaluations: 1 + method: average + comparison_operator: gt + metadata: SG1 + action: [SP1] + ''' + triggers = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['triggers'][0] + name = list(triggers.keys())[0] + Triggers(name, triggers[name]) + + def test_policy_trigger_invalid_keyname_senlin_resources(self): tpl_snippet = ''' triggers: - resize_compute: @@ -1646,6 +1680,34 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml lambda: Triggers(name, triggers[name])) self.assertEqual(expectedmessage, err.__str__()) + def test_policy_trigger_invalid_keyname_heat_resources(self): + tpl_snippet = ''' + triggers: + - high_cpu_usage: + description: trigger + meter_name: cpu_util + condition: + constraint: utilization greater_than 60% + threshold: 60 + period: 600 + evaluations: 1 + method: average + comparison_operator: gt + metadata1: SG1 + action: [SP1] + ''' + triggers = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['triggers'][0] + name = list(triggers.keys())[0] + expectedmessage = _( + 'Triggers "high_cpu_usage" contains unknown field ' + '"metadata1". Refer to the definition ' + 'to verify valid values.') + err = self.assertRaises( + exception.UnknownFieldError, + lambda: Triggers(name, triggers[name])) + self.assertEqual(expectedmessage, err.__str__()) + def test_policy_missing_required_keyname(self): tpl_snippet = ''' policies: |