[CORD-2715] making sure we are not deleting object with must-exist key set to true, as they are included for reference
Change-Id: I07587e6f57b4558554712d67cd21f161c4fe8df5
(cherry picked from commit 91d7aebf39a6e3fdc374eef59cb9e9536211c296)
diff --git a/test/test_tosca_parser_e2e.py b/test/test_tosca_parser_e2e.py
index 6a44b6f..2d2649f 100644
--- a/test/test_tosca_parser_e2e.py
+++ b/test/test_tosca_parser_e2e.py
@@ -41,6 +41,9 @@
class FakeUser:
objects = FakeObj
+class FakeNode:
+ objects = FakeObj
+
USERNAME = "username"
PASSWORD = "pass"
@@ -49,7 +52,8 @@
'XOSGuiExtension': FakeGuiExt,
'Site': FakeSite,
'User': FakeUser,
- 'Instance': FakeInstance
+ 'Instance': FakeInstance,
+ 'Node': FakeNode
}
class TOSCA_Parser_E2E(unittest.TestCase):
@@ -97,8 +101,9 @@
@patch.dict(RESOURCES, mock_resources, clear=True)
@patch.object(FakeGuiExt.objects, 'filter', MagicMock(return_value=[FakeModel]))
+ @patch.object(FakeNode.objects, 'filter', MagicMock(return_value=[FakeModel]))
@patch.object(FakeModel, 'delete')
- def test_basic_deletion(self, mock_delete):
+ def test_basic_deletion(self, mock_model):
"""
[TOSCA_Parser] Should delete models defined in a TOSCA recipe
"""
@@ -108,12 +113,18 @@
description: Persist xos-sample-gui-extension
imports:
- - custom_types/xosguiextension.yaml
+ - custom_types/node.yaml
+ - custom_types/xosguiextension.yaml
topology_template:
node_templates:
- # UI Extension
+ should_stay:
+ type: tosca.nodes.Node
+ properties:
+ name: should_stay
+ must-exist: true
+
test:
type: tosca.nodes.XOSGuiExtension
properties:
@@ -126,10 +137,10 @@
parser.execute()
# checking that the model has been saved
- mock_delete.assert_called()
+ mock_model.assert_called_once()
self.assertIsNotNone(parser.templates_by_model_name['test'])
- self.assertEqual(parser.ordered_models_name, ['test'])
+ self.assertEqual(parser.ordered_models_name, ['test', 'should_stay'])
@patch.dict(RESOURCES, mock_resources, clear=True)
@patch.object(FakeSite.objects, 'filter', MagicMock(return_value=[FakeModel]))