mcouthon closed pull request #222: Change networkx requirement
URL: https://github.com/apache/incubator-ariatosca/pull/222
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/aria/__init__.py b/aria/__init__.py
index 980a2bb1..9ceeaefd 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -66,10 +66,16 @@ def install_aria_extensions(strict=True):
     extension.init()
 
 
-def application_model_storage(api, api_kwargs=None, initiator=None, 
initiator_kwargs=None):
+def application_model_storage(api, api_kwargs=None, initiator=None, 
initiator_kwargs=None,
+                              models_prefix=None):
     """
     Initiate model storage.
     """
+    if models_prefix:
+        metadata = modeling.models.aria_declarative_base.metadata
+        for table in metadata.sorted_tables:
+            if not table.name.startswith(models_prefix):
+                table.name = models_prefix + table.name
     return storage.ModelStorage(api_cls=api,
                                 api_kwargs=api_kwargs,
                                 items=modeling.models.models_to_register,
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index da912959..9c0b46e6 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -426,7 +426,7 @@ def plugin_fk(cls):
     _api_id = Column(String)
     _executor = Column(PickleType)
     _context_cls = Column(PickleType)
-    _stub_type = Column(Enum(*STUB_TYPES))
+    _stub_type = Column(Enum(*STUB_TYPES, name='stub_type'))
 
     @property
     def actor(self):
diff --git a/requirements.in b/requirements.in
index e8bc336c..c9666e49 100644
--- a/requirements.in
+++ b/requirements.in
@@ -23,7 +23,7 @@ colorama>=0.3, <=0.4
 Jinja2>=2.9, <3.0
 jsonpickle>=0.9, <=1.0
 logutils>=0.3, <0.4
-networkx>=2.0, <2.1
+networkx>=1.9, <2.0
 PrettyTable>=0.7, <0.8
 psutil>=5.4, <5.5
 requests>=2.3, <2.14
diff --git a/requirements.txt b/requirements.txt
index 74fe9d52..a6aa5bf3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,7 +18,7 @@ lockfile==0.12.2          # via cachecontrol
 logutils==0.3.5
 markupsafe==1.0           # via jinja2
 msgpack-python==0.4.8     # via cachecontrol
-networkx==2.0
+networkx==1.11
 prettytable==0.7.2
 psutil==5.4.1
 requests==2.13.0
diff --git a/tests/test_init.py b/tests/test_init.py
new file mode 100644
index 00000000..d6075448
--- /dev/null
+++ b/tests/test_init.py
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from aria import storage, modeling
+from aria import application_model_storage
+
+
+def test_models_prefix(mocker):
+    prefix = 'tosca_'
+    models_to_register = modeling.models.models_to_register
+    try:
+        mocker.patch.object(storage, 'ModelStorage')
+        application_model_storage(None, models_prefix=prefix)
+        assert all(model.__table__.name.startswith(prefix) for model in 
models_to_register)
+    finally:
+        for model in models_to_register:
+            model.__table__.name = model.__table__.name.replace(prefix, '')
diff --git a/tox.ini b/tox.ini
index d642f174..4adf9c06 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,7 +11,7 @@
 # limitations under the License.
 
 [tox]
-envlist=core,extensions,e2e,windows,ssh,pylint_core,pylint_tests,docs
+envlist=core,customdb,extensions,e2e,windows,ssh,pylint_core,pylint_tests,docs
 pytest_processes={env:CONCURRENCY:auto}
 pylint_jobs={env:CONCURRENCY:0}
 
@@ -30,6 +30,7 @@ deps=
     tests/requirements.txt
 basepython=
   core: python2.7
+  customdb: python2.7
   extensions: python2.7
   e2e: python2.7
   ssh: python2.7
@@ -48,6 +49,13 @@ commands=
     --cov-report term-missing \
     --cov aria
 
+[testenv:customdb]
+commands=
+  pytest tests/test_init.py \
+    --numprocesses={[tox]pytest_processes} \
+    --cov-report term-missing \
+    --cov aria
+
 [testenv:extensions]
 commands=
   pytest tests/extensions \


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to