You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2016/12/22 15:56:14 UTC

incubator-ariatosca git commit: fixed _privatre_fileds test

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-39-Genericize-storage-models 602760e5f -> e24f06a7d


fixed _privatre_fileds test


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

Branch: refs/heads/ARIA-39-Genericize-storage-models
Commit: e24f06a7d1982ea20d0882ffbf56f32aa4b72531
Parents: 602760e
Author: mxmrlv <mx...@gmail.com>
Authored: Thu Dec 22 17:21:11 2016 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Thu Dec 22 17:56:04 2016 +0200

----------------------------------------------------------------------
 aria/storage/base_model.py          |  6 +--
 aria/storage/structure.py           |  4 +-
 tests/mock/models.py                |  4 +-
 tests/storage/test_model_storage.py |  6 ---
 tests/storage/test_models.py        | 74 ++++++++++++++++----------------
 5 files changed, 43 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e24f06a7/aria/storage/base_model.py
----------------------------------------------------------------------
diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py
index 9162c56..c7eb27c 100644
--- a/aria/storage/base_model.py
+++ b/aria/storage/base_model.py
@@ -106,9 +106,9 @@ class DeploymentBase(ModelMixin):
     policy_triggers = Column(Dict)
     policy_types = Column(Dict)
     outputs = Column(Dict)
-    scaling_groups = Column(List)
+    scaling_groups = Column(Dict)
     updated_at = Column(DateTime)
-    workflows = Column(List)
+    workflows = Column(Dict)
 
     @declared_attr
     def blueprint_fk(cls):
@@ -215,7 +215,7 @@ class DeploymentUpdateBase(ModelMixin):
 
     created_at = Column(DateTime, nullable=False, index=True)
     deployment_plan = Column(Dict, nullable=False)
-    deployment_update_node_instances = Column(List)
+    deployment_update_node_instances = Column(Dict)
     deployment_update_deployment = Column(Dict)
     deployment_update_nodes = Column(List)
     modified_entity_ids = Column(Dict)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e24f06a7/aria/storage/structure.py
----------------------------------------------------------------------
diff --git a/aria/storage/structure.py b/aria/storage/structure.py
index c307041..d222c94 100644
--- a/aria/storage/structure.py
+++ b/aria/storage/structure.py
@@ -39,8 +39,6 @@ from sqlalchemy import (
 
 class ModelMixin(object):
 
-    # _private_fields = []
-
     @classmethod
     def id_column_name(cls):
         raise NotImplementedError
@@ -161,7 +159,7 @@ class ModelMixin(object):
         """
         fields = set(cls._association_proxies())
         fields.update(cls.__table__.columns.keys())
-        return fields - set(cls._private_fields)
+        return fields - set(getattr(cls, '_private_fields', []))
 
     def __repr__(self):
         return '<{__class__.__name__} id=`{id}`>'.format(

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e24f06a7/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index c878cd6..8229038 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -140,14 +140,14 @@ def get_deployment(blueprint):
         description='',
         created_at=now,
         updated_at=now,
-        workflows=[],
+        workflows={},
         inputs={},
         groups={},
         permalink='',
         policy_triggers={},
         policy_types={},
         outputs={},
-        scaling_groups=[],
+        scaling_groups={},
     )
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e24f06a7/tests/storage/test_model_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py
index 4991d19..6f9527e 100644
--- a/tests/storage/test_model_storage.py
+++ b/tests/storage/test_model_storage.py
@@ -130,12 +130,6 @@ def test_model_to_dict():
     assert 'blueprint_fk' not in deployment_dict
 
 
-def test_missing_private_fields():
-    mock_model = MockModel()
-    with pytest.raises(AttributeError):
-        mock_model.to_dict()
-
-
 def test_application_storage_factory():
     storage = application_model_storage(sql_mapi.SQLAlchemyModelAPI,
                                         api_kwargs=get_sqlite_api_kwargs())

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e24f06a7/tests/storage/test_models.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py
index 09fbacd..df81f95 100644
--- a/tests/storage/test_models.py
+++ b/tests/storage/test_models.py
@@ -213,32 +213,32 @@ class TestDeployment(object):
         'is_valid, name, created_at, description, inputs, groups, permalink, policy_triggers, '
         'policy_types, outputs, scaling_groups, updated_at, workflows',
         [
-            (False, m_cls, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (False, 'name', m_cls, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (False, 'name', now, m_cls, {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (False, 'name', now, 'desc', m_cls, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (False, 'name', now, 'desc', {}, m_cls, 'perlnk', {}, {}, {}, [], now, []),
-            (False, 'name', now, 'desc', {}, {}, m_cls, {}, {}, {}, [], now, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', m_cls, {}, {}, [], now, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, m_cls, {}, [], now, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, m_cls, [], now, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, m_cls, now, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], m_cls, []),
-            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, m_cls),
-
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (True, None, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (True, 'name', now, None, {}, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', None, {}, 'perlnk', {}, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, None, 'perlnk', {}, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, None, {}, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', None, {}, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, None, {}, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, None, [], now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, None, now, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], None, []),
-            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, [], now, None),
+            (False, m_cls, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (False, 'name', m_cls, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (False, 'name', now, m_cls, {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (False, 'name', now, 'desc', m_cls, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (False, 'name', now, 'desc', {}, m_cls, 'perlnk', {}, {}, {}, {}, now, {}),
+            (False, 'name', now, 'desc', {}, {}, m_cls, {}, {}, {}, {}, now, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', m_cls, {}, {}, {}, now, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, m_cls, {}, {}, now, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, m_cls, {}, now, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, m_cls, now, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, m_cls, {}),
+            (False, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, m_cls),
+
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, None, now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, 'name', now, None, {}, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', None, {}, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, None, 'perlnk', {}, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, None, {}, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', None, {}, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, None, {}, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, None, {}, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, None, now, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, None, {}),
+            (True, 'name', now, 'desc', {}, {}, 'perlnk', {}, {}, {}, {}, now, None),
         ]
     )
     def test_deployment_model_creation(self, deployment_storage, is_valid, name, created_at,
@@ -381,20 +381,20 @@ class TestDeploymentUpdate(object):
         'is_valid, created_at, deployment_plan, deployment_update_node_instances, '
         'deployment_update_deployment, deployment_update_nodes, modified_entity_ids, state',
         [
-            (False, m_cls, {}, [], {}, [], {}, 'state'),
-            (False, now, m_cls, [], {}, [], {}, 'state'),
+            (False, m_cls, {}, {}, {}, [], {}, 'state'),
+            (False, now, m_cls, {}, {}, [], {}, 'state'),
             (False, now, {}, m_cls, {}, [], {}, 'state'),
-            (False, now, {}, [], m_cls, [], {}, 'state'),
-            (False, now, {}, [], {}, m_cls, {}, 'state'),
-            (False, now, {}, [], {}, [], m_cls, 'state'),
-            (False, now, {}, [], {}, [], {}, m_cls),
+            (False, now, {}, {}, m_cls, [], {}, 'state'),
+            (False, now, {}, {}, {}, m_cls, {}, 'state'),
+            (False, now, {}, {}, {}, [], m_cls, 'state'),
+            (False, now, {}, {}, {}, [], {}, m_cls),
 
-            (True, now, {}, [], {}, [], {}, 'state'),
+            (True, now, {}, {}, {}, [], {}, 'state'),
             (True, now, {}, None, {}, [], {}, 'state'),
-            (True, now, {}, [], None, [], {}, 'state'),
-            (True, now, {}, [], {}, None, {}, 'state'),
-            (True, now, {}, [], {}, [], None, 'state'),
-            (True, now, {}, [], {}, [], {}, None),
+            (True, now, {}, {}, None, [], {}, 'state'),
+            (True, now, {}, {}, {}, None, {}, 'state'),
+            (True, now, {}, {}, {}, [], None, 'state'),
+            (True, now, {}, {}, {}, [], {}, None),
         ]
     )
     def test_deployment_update_model_creation(self, deployment_storage, is_valid, created_at,