Merge "Return input default value on get_input evaluation"

This commit is contained in:
Jenkins 2015-04-07 02:39:05 +00:00 committed by Gerrit Code Review
commit 14af005318
3 changed files with 17 additions and 1 deletions

View File

@ -81,7 +81,9 @@ class GetInput(Function):
raise UnknownInputError(input_name=self.args[0])
def result(self):
return self
found_input = [input_def for input_def in self.tosca_tpl.inputs
if self.input_name == input_def.name][0]
return found_input.default
@property
def input_name(self):

View File

@ -15,6 +15,7 @@ inputs:
db_name:
type: string
description: The name of the database.
default: wordpress
db_user:
type: string
description: The user name of the DB user.
@ -27,6 +28,7 @@ inputs:
db_port:
type: integer
description: Port for the MySQL database.
default: 3306
node_templates:
wordpress:

View File

@ -37,6 +37,10 @@ class IntrinsicFunctionsTest(TestCase):
interface for interface in interfaces
if interface.name == operation][0]
def _get_property(self, node_template, property_name):
return [prop.value for prop in node_template.properties
if prop.name == property_name][0]
def test_get_property(self):
mysql_dbms = self._get_node('mysql_dbms')
operation = self._get_operation(mysql_dbms.interfaces, 'configure')
@ -97,6 +101,14 @@ class IntrinsicFunctionsTest(TestCase):
self._load_template,
'functions/test_unknown_input_in_interface.yaml')
def test_get_input_default_value_result(self):
mysql_dbms = self._get_node('mysql_dbms')
dbms_port = self._get_property(mysql_dbms, 'dbms_port')
self.assertEqual(3306, dbms_port.result())
dbms_root_password = self._get_property(mysql_dbms,
'dbms_root_password')
self.assertIsNone(dbms_root_password.result())
class GetAttributeTest(TestCase):