Merge "Return input default value on get_input evaluation"
This commit is contained in:
commit
14af005318
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user