ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject [4/6] incubator-ariatosca git commit: ARIA-132-fixed-support-for-cascading-deletion
Date Wed, 05 Apr 2017 15:58:24 GMT
ARIA-132-fixed-support-for-cascading-deletion


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/e7ffc735
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/e7ffc735
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/e7ffc735

Branch: refs/heads/ARIA-134-populate-workflows
Commit: e7ffc7353dd2f23fdffde22bdb2ffac20542d601
Parents: 369323b
Author: max-orlov <maxim@gigaspaces.com>
Authored: Tue Apr 4 12:22:12 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Tue Apr 4 12:22:12 2017 +0300

----------------------------------------------------------------------
 aria/modeling/relationship.py       |  3 ++-
 tests/storage/test_model_storage.py | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e7ffc735/aria/modeling/relationship.py
----------------------------------------------------------------------
diff --git a/aria/modeling/relationship.py b/aria/modeling/relationship.py
index ac1de28..e6830b8 100644
--- a/aria/modeling/relationship.py
+++ b/aria/modeling/relationship.py
@@ -193,7 +193,8 @@ def one_to_many(model_class,
         child_table,
         back_populates=back_populates,
         other_fk=child_fk,
-        dict_key=dict_key)
+        dict_key=dict_key,
+        relationship_kwargs=dict(cascade='all'))
 
 
 def many_to_one(model_class,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e7ffc735/tests/storage/test_model_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py
index fa57e6f..e4f3eba 100644
--- a/tests/storage/test_model_storage.py
+++ b/tests/storage/test_model_storage.py
@@ -108,6 +108,19 @@ def test_application_storage_factory():
     tests_storage.release_sqlite_storage(storage)
 
 
+def test_cascade_deletion(context):
+    service = context.model.service.list()[0]
+
+    assert len(context.model.service_template.list()) == 1
+    assert len(service.nodes) == len(context.model.node.list()) == 2
+
+    context.model.service.delete(service)
+
+    assert len(context.model.service_template.list()) == 1
+    assert len(context.model.service.list()) == 0
+    assert len(context.model.node.list()) == 0
+
+
 @pytest.fixture
 def context(tmpdir):
     result = mock.context.simple(str(tmpdir))


Mime
View raw message