 0d23118af2
			
		
	
	0d23118af2
	
	
	
		
			
			Parse the TOSCA template as per the specification defined in TOSCA Simple Profile in YAML v1.0 working draft 1. Partially Implements: blueprint heat-translator-tosca Change-Id: I9d71a28b7b48b7591a55c2b0947ce63beb335bbf
		
			
				
	
	
		
			64 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # vim: tabstop=4 shiftwidth=4 softtabstop=4
 | |
| 
 | |
| #
 | |
| #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 | |
| #    not use this file except in compliance with the License. You may obtain
 | |
| #    a copy of the License at
 | |
| #
 | |
| #         http://www.apache.org/licenses/LICENSE-2.0
 | |
| #
 | |
| #    Unless required by applicable law or agreed to in writing, software
 | |
| #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | |
| #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 | |
| #    License for the specific language governing permissions and limitations
 | |
| #    under the License.
 | |
| 
 | |
| from translator.toscalib.elements.nodetype import NodeType
 | |
| from translator.toscalib.tests.base import TestCase
 | |
| compute_type = NodeType('tosca.nodes.Compute')
 | |
| component_type = NodeType('tosca.nodes.SoftwareComponent')
 | |
| 
 | |
| 
 | |
| class ToscaDefTest(TestCase):
 | |
|     def test_type(self):
 | |
|         self.assertEqual(compute_type.type, "tosca.nodes.Compute")
 | |
|         self.assertRaises(ValueError, NodeType, 'tosca.nodes.Invalid')
 | |
| 
 | |
|     def test_parent_type(self):
 | |
|         self.assertEqual(compute_type.parent_type.type, "tosca.nodes.Root")
 | |
| 
 | |
|     def test_capabilities(self):
 | |
|         self.assertEqual(
 | |
|             ['tosca.capabilities.Container'],
 | |
|             [c.type for c in compute_type.capabilities])
 | |
| 
 | |
|     def test_properties_def(self):
 | |
|         self.assertEqual(
 | |
|             ['disk_size', 'ip_address', 'mem_size',
 | |
|              'num_cpus', 'os_arch', 'os_distribution',
 | |
|              'os_type', 'os_version'],
 | |
|             sorted([p.name for p in compute_type.properties_def]))
 | |
|         self.assertTrue([p.required for p in compute_type.properties_def
 | |
|                          if p.name == 'os_type'])
 | |
| 
 | |
|     def test_requirements(self):
 | |
|         self.assertEqual(compute_type.requirements, None)
 | |
|         self.assertEqual(
 | |
|             [{'host': 'tosca.nodes.Compute'}],
 | |
|             [r for r in component_type.requirements])
 | |
| 
 | |
|     def test_relationship(self):
 | |
|         self.assertEqual(
 | |
|             [('tosca.relationships.HostedOn', 'tosca.nodes.Compute')],
 | |
|             [(relation.type, node.type) for
 | |
|              relation, node in component_type.relationship.items()])
 | |
|         self.assertIn(
 | |
|             ('tosca.relationships.HostedOn', ['tosca.capabilities.Container']),
 | |
|             [(relation.type, relation.valid_targets) for
 | |
|              relation in list(component_type.relationship.keys())])
 | |
| 
 | |
|     def test_interfaces(self):
 | |
|         self.assertEqual(compute_type.interfaces, None)
 | |
|         root_node = NodeType('tosca.nodes.Root')
 | |
|         self.assertIn('tosca.interfaces.node.Lifecycle', root_node.interfaces)
 |