SEBA-513 Tosca engine should not require fields with Default set
Change-Id: I3e8f43684e82c5a29c27b249853925e8fa2c588b
diff --git a/Dockerfile b/Dockerfile
index 6d30cda..9bef324 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,8 @@
# docker build -t xosproject/xos-tosca:candidate .
# xosproject/xos-tosca
-FROM xosproject/xos-client:2.1.32
+
+FROM xosproject/xos-client:2.2.11
# Set environment variables
ENV CODE_SOURCE .
diff --git a/VERSION b/VERSION
index 18efdb9..512a1fa 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.8
+1.1.9
diff --git a/src/tosca/xtarget/tosca.xtarget b/src/tosca/xtarget/tosca.xtarget
index f0eb78b..19aeb60 100644
--- a/src/tosca/xtarget/tosca.xtarget
+++ b/src/tosca/xtarget/tosca.xtarget
@@ -12,7 +12,7 @@
# properties:
# must-exist: true # optional to reference models created in other recipes
{%- for f in (m.fields + xproto_base_fields(m, proto.message_table)) | sort(attribute='name') %}
-{%- if not f.link and xproto_tosca_required(f.options.null, f.options.blank, f.options.default) %}
+{%- if not f.link and xproto_tosca_required(f.options.null, f.options.blank, f.options.default, f.options.modifier) %}
# {{ f.name }}: <value>
{%- endif -%}
{%- endfor %}
@@ -34,7 +34,7 @@
{%- if not f.link -%}
{{ f.name }}:
type: {{ xproto_tosca_field_type(f.type) }}
- required: {{ xproto_tosca_required(f.options.null, f.options.blank, f.options.default) }}
+ required: {{ xproto_tosca_required(f.options.null, f.options.blank, f.options.default, f.options.modifier) }}
description: {{ f.options.help_text }}
{% endif %}
{%- endfor %}
diff --git a/test/test_tosca_parser_e2e.py b/test/test_tosca_parser_e2e.py
index 124e160..8a1b7e8 100644
--- a/test/test_tosca_parser_e2e.py
+++ b/test/test_tosca_parser_e2e.py
@@ -35,7 +35,7 @@
class FakeSite:
objects = FakeObj
-class FakeInstance:
+class FakePrivilege:
objects = FakeObj
class FakeUser:
@@ -52,7 +52,7 @@
'XOSGuiExtension': FakeGuiExt,
'Site': FakeSite,
'User': FakeUser,
- 'Instance': FakeInstance,
+ 'Privilege': FakePrivilege,
'Node': FakeNode
}
@@ -238,7 +238,7 @@
self.assertEqual(e.exception.message.message, "[XOS-TOSCA] Model of class Site and properties {'name': 'Open Networking Lab'} has property 'must-exist' but cannot be found")
@patch.dict(RESOURCES, mock_resources, clear=True)
- @patch.object(FakeInstance.objects, 'filter', MagicMock(return_value=[FakeModel]))
+ @patch.object(FakePrivilege.objects, 'filter', MagicMock(return_value=[FakeModel]))
@patch.object(FakeModel, 'save')
def test_number_param(self, mock_save):
"""
@@ -250,17 +250,16 @@
description: Create a new site with one user
imports:
- - custom_types/instance.yaml
+ - custom_types/privilege.yaml
topology_template:
node_templates:
- # Site
- instance#test_instance:
- type: tosca.nodes.Instance
+ privilege#test_privilege:
+ type: tosca.nodes.Privilege
properties:
- name: test_instance
- numberCores: 10
+ permission: whatever
+ accessor_id: 3
"""
parser = TOSCA_Parser(recipe, USERNAME, PASSWORD)
parser.execute()
@@ -269,6 +268,6 @@
mock_save.assert_called()
# check that the model was saved with the expected values
- saved_model = parser.saved_model_by_name['instance#test_instance']
- self.assertEqual(saved_model.name, 'test_instance')
- self.assertEqual(saved_model.numberCores, 10)
+ saved_model = parser.saved_model_by_name['privilege#test_privilege']
+ self.assertEqual(saved_model.permission, 'whatever')
+ self.assertEqual(saved_model.accessor_id, 3)