tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_single_instance_wordpress.yaml")
- tosca = ToscaTemplate(tosca_tpl)
+ params = {'db_name': 'my_wordpress', 'db_user': 'my_db_user',
+ 'db_root_pwd': '12345678'}
+ tosca = ToscaTemplate(tosca_tpl, parsed_params=params)
tosca_elk_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_elk.yaml")
tosca_repo_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- "data/tosca_repositories_test_definition.yaml")
+ "data/repositories/tosca_repositories_test_definition.yaml")
def test_version(self):
self.assertEqual(self.tosca.version, "tosca_simple_yaml_1_0")
wordpress_node.is_derived_from("tosca.nodes.Root"))
self.assertFalse(
wordpress_node.is_derived_from("tosca.policies.Root"))
- self.assertFalse(
- wordpress_node.is_derived_from("tosca.groups.Root"))
def test_outputs(self):
self.assertEqual(
self.assertEqual(3, len(interface.inputs))
TestCase.skip(self, 'bug #1440247')
wp_db_port = interface.inputs['wp_db_port']
- self.assertTrue(isinstance(wp_db_port, GetProperty))
+ self.assertIsInstance(wp_db_port, GetProperty)
self.assertEqual('get_property', wp_db_port.name)
self.assertEqual(['SELF',
'database_endpoint',
'port'],
wp_db_port.args)
result = wp_db_port.result()
- self.assertTrue(isinstance(result, GetInput))
+ self.assertIsInstance(result, GetInput)
else:
raise AssertionError(
'Unexpected interface: {0}'.format(interface.name))
compute_type = NodeType(tpl.type)
self.assertEqual(
sorted(['tosca.capabilities.Container',
+ 'tosca.capabilities.Endpoint.Admin',
'tosca.capabilities.Node',
'tosca.capabilities.OperatingSystem',
'tosca.capabilities.network.Bindable',
tosca_tpl = self._load_template('test_no_outputs_in_template.yaml')
self.assertEqual(0, len(tosca_tpl.outputs))
+ def test_template_file_with_suffix_yml(self):
+ tosca_tpl = self._load_template('custom_types/wordpress.yml')
+ self.assertIsNotNone(tosca_tpl)
+
def test_relationship_interface(self):
template = ToscaTemplate(self.tosca_elk_tpl)
for node_tpl in template.nodetemplates:
"""
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- "data/test_requirements.yaml")
+ "data/requirements/test_requirements.yaml")
tosca = ToscaTemplate(tosca_tpl)
for node_tpl in tosca.nodetemplates:
if node_tpl.name == 'my_app':
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_single_instance_wordpress.yaml")
- tosca = ToscaTemplate(tosca_tpl)
+ params = {'db_name': 'my_wordpress', 'db_user': 'my_db_user',
+ 'db_root_pwd': '12345678'}
+ tosca = ToscaTemplate(tosca_tpl, parsed_params=params)
self.assertTrue(tosca.topology_template.custom_defs)
def test_local_template_with_url_import(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_single_instance_wordpress_with_url_import.yaml")
- tosca = ToscaTemplate(tosca_tpl)
+ tosca = ToscaTemplate(tosca_tpl,
+ parsed_params={'db_root_pwd': '123456'})
self.assertTrue(tosca.topology_template.custom_defs)
def test_url_template_with_local_relpath_import(self):
os.path.dirname(os.path.abspath(__file__)),
"data/test_instance_nested_imports.yaml")
tosca = ToscaTemplate(tosca_tpl)
- expected_custom_types = ['tosca.nodes.WebApplication.WordPress',
+ expected_custom_types = ['tosca.nodes.SoftwareComponent.Kibana',
+ 'tosca.nodes.WebApplication.WordPress',
'test_namespace_prefix.Rsyslog',
'Test2ndRsyslogType',
'test_2nd_namespace_prefix.Rsyslog',
exception.ExceptionCollector.assertExceptionMessage(
exception.UnknownFieldError, err7_msg)
- err8_msg = _('\'Node template "server1" was not found.\'')
+ err8_msg = _('\'Node template "server1" was not found in '
+ '"webserver".\'')
exception.ExceptionCollector.assertExceptionMessage(
KeyError, err8_msg)
exception.ExceptionCollector.assertExceptionMessage(
exception.MissingRequiredFieldError, err9_msg)
+ err10_msg = _('Type "tosca.nodes.XYZ" is not a valid type.')
+ exception.ExceptionCollector.assertExceptionMessage(
+ exception.InvalidTypeError, err10_msg)
+
def test_invalid_section_names(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
self.assertEqual(tosca.version, "tosca_simple_yaml_1_0")
+ def test_yaml_dict_tpl_with_version_1_1(self):
+ test_tpl = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "data/tosca_helloworld_with_version_1_1.yaml")
+
+ yaml_dict_tpl = toscaparser.utils.yamlparser.load_yaml(test_tpl)
+
+ tosca = ToscaTemplate(yaml_dict_tpl=yaml_dict_tpl)
+
+ self.assertEqual(tosca.version, "tosca_simple_yaml_1_1")
+
def test_yaml_dict_tpl_with_params_and_url_import(self):
test_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_single_instance_wordpress.yaml")
yaml_dict_tpl = toscaparser.utils.yamlparser.load_yaml(test_tpl)
-
+ params = {'db_name': 'my_wordpress', 'db_user': 'my_db_user',
+ 'db_root_pwd': '12345678'}
self.assertRaises(exception.ValidationError, ToscaTemplate, None,
- None, False, yaml_dict_tpl)
+ params, False, yaml_dict_tpl)
err_msg = (_('Relative file name "custom_types/wordpress.yaml" '
'cannot be used in a pre-parsed input template.'))
exception.ExceptionCollector.assertExceptionMessage(ImportError,
def test_node_filter(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- "data/test_node_filter.yaml")
+ "data/node_filter/test_node_filter.yaml")
ToscaTemplate(tosca_tpl)
def test_attributes_inheritance(self):
def test_repositories_definition(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- "data/test_repositories_definition.yaml")
+ "data/repositories/test_repositories_definition.yaml")
ToscaTemplate(tosca_tpl)
def test_custom_caps_def(self):
def test_containers(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- "data/test_containers.yaml")
+ "data/containers/test_container_docker_mysql.yaml")
ToscaTemplate(tosca_tpl, parsed_params={"mysql_root_pwd": "12345678"})
+
+ def test_endpoint_on_compute(self):
+ tosca_tpl = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "data/test_endpoint_on_compute.yaml")
+ ToscaTemplate(tosca_tpl)
+
+ def test_nested_dsl_def(self):
+ tosca_tpl = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "data/dsl_definitions/test_nested_dsl_def.yaml")
+ self.assertIsNotNone(ToscaTemplate(tosca_tpl))
+
+ def test_multiple_policies(self):
+ tosca_tpl = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ "data/policies/test_tosca_nfv_multiple_policies.yaml")
+ tosca = ToscaTemplate(tosca_tpl)
+ self.assertEqual(
+ ['ALRM1', 'SP1', 'SP2'],
+ sorted([policy.name for policy in tosca.policies]))