Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-1-parser-test-suite 1dfb81c8a -> 71cf541f7
More fixes Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/71cf541f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/71cf541f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/71cf541f Branch: refs/heads/ARIA-1-parser-test-suite Commit: 71cf541f727ad6b80f7c05d8c37f7fe60b42cd12 Parents: 1dfb81c Author: Tal Liron <[email protected]> Authored: Mon Nov 27 16:46:11 2017 -0600 Committer: Tal Liron <[email protected]> Committed: Mon Nov 27 16:46:11 2017 -0600 ---------------------------------------------------------------------- aria/parser/consumption/presentation.py | 5 ++++- aria/parser/loading/file.py | 3 +++ aria/parser/loading/loader.py | 14 ++++++++++---- aria/parser/loading/request.py | 6 ++++++ aria/parser/reading/yaml.py | 2 +- tests/cli/test_node_templates.py | 2 +- tests/cli/test_nodes.py | 2 +- tests/cli/test_service_templates.py | 2 +- tests/cli/test_services.py | 2 +- tests/end2end/test_hello_world.py | 2 +- tests/end2end/test_nodecellar.py | 2 +- tests/mechanisms/web_server.py | 2 +- tests/mock/workflow.py | 2 +- tests/modeling/__init__.py | 2 +- tests/orchestrator/context/test_operation.py | 4 ++-- tests/orchestrator/context/test_serialize.py | 3 ++- tests/orchestrator/context/test_workflow.py | 2 +- .../orchestrator/execution/test_execution_compiler.py | 3 ++- tests/orchestrator/execution_plugin/test_local.py | 2 +- tests/orchestrator/execution_plugin/test_ssh.py | 2 +- .../workflows/executor/test_process_executor.py | 2 +- .../executor/test_process_executor_extension.py | 2 +- .../executor/test_process_executor_tracked_changes.py | 6 +++--- tests/storage/test_model_storage.py | 4 ++-- tests/test_extension.py | 4 ++-- tests/utils/test_plugin.py | 2 +- tests/utils/test_versions.py | 2 +- 27 files changed, 53 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/aria/parser/consumption/presentation.py ---------------------------------------------------------------------- diff --git a/aria/parser/consumption/presentation.py b/aria/parser/consumption/presentation.py index 0f0b380..9bddd5e 100644 --- a/aria/parser/consumption/presentation.py +++ b/aria/parser/consumption/presentation.py @@ -181,7 +181,10 @@ class Read(Consumer): else: cache_key = None - canonical_location = loader.get_canonical_location() + try: + canonical_location = loader.get_canonical_location() + except NotImplementedError: + canonical_location = None # Because retrieving the canonical location can be costly, we will try to cache it if cache_key is not None: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/aria/parser/loading/file.py ---------------------------------------------------------------------- diff --git a/aria/parser/loading/file.py b/aria/parser/loading/file.py index f6fd284..719e770 100644 --- a/aria/parser/loading/file.py +++ b/aria/parser/loading/file.py @@ -63,3 +63,6 @@ class FileTextLoader(Loader): except Exception as e: raise LoaderException(u'file error {0}'.format(self.path), cause=e) return None + + def get_canonical_location(self): + raise NotImplementedError http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/aria/parser/loading/loader.py ---------------------------------------------------------------------- diff --git a/aria/parser/loading/loader.py b/aria/parser/loading/loader.py index a1dc3c6..92b44ee 100644 --- a/aria/parser/loading/loader.py +++ b/aria/parser/loading/loader.py @@ -20,8 +20,14 @@ class Loader(object): Loaders extract a document by consuming a document source. - Though the extracted document is often textual (a string or string-like - data), loaders may provide any format. + Though the extracted document is often textual (a string or string-like data), loaders may + provide any format. + + Loaders can also calculate the "canonical location" of what they are loading, which is a + globally unique reference that can be used as a cache key. Examples include absolute file paths + and de-relativized URIs. Note that calculating the canonical location can be very costly + (for example, hitting various URLs until finding an existing one), and thus it's a good idea + to cache the canonical location per loader context. """ def open(self): @@ -33,5 +39,5 @@ class Loader(object): def load(self): raise NotImplementedError - def get_canonical_location(self): # pylint: disable=no-self-use - return None + def get_canonical_location(self): + raise NotImplementedError http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/aria/parser/loading/request.py ---------------------------------------------------------------------- diff --git a/aria/parser/loading/request.py b/aria/parser/loading/request.py index 5f12055..199353a 100644 --- a/aria/parser/loading/request.py +++ b/aria/parser/loading/request.py @@ -71,6 +71,9 @@ class RequestLoader(Loader): self._response = None raise LoaderException(u'request error {0:d}: "{1}"'.format(status, self.uri)) + def get_canonical_location(self): + raise NotImplementedError + class RequestTextLoader(RequestLoader): """ @@ -86,3 +89,6 @@ class RequestTextLoader(RequestLoader): except Exception as e: raise LoaderException(u'request error: {0}'.format(self.uri), cause=e) return None + + def get_canonical_location(self): + raise NotImplementedError http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/aria/parser/reading/yaml.py ---------------------------------------------------------------------- diff --git a/aria/parser/reading/yaml.py b/aria/parser/reading/yaml.py index d843859..3735d5e 100644 --- a/aria/parser/reading/yaml.py +++ b/aria/parser/reading/yaml.py @@ -92,7 +92,7 @@ class YamlReader(Reader): try: # Faster C-based loader, might not be available on all platforms yaml_loader = yaml.CSafeLoader(data) - except BaseException: + except Exception: yaml_loader = yaml.SafeLoader(data) try: node = yaml_loader.get_single_node() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/cli/test_node_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py index ff7ff28..548d968 100644 --- a/tests/cli/test_node_templates.py +++ b/tests/cli/test_node_templates.py @@ -18,7 +18,7 @@ from mock import ANY, MagicMock from aria.cli.env import _Environment -from .base_test import ( # pylint: disable=unused-import +from .base_test import ( # pylint: disable=unused-import TestCliBase, mock_storage ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/cli/test_nodes.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_nodes.py b/tests/cli/test_nodes.py index 0233989..4d089a6 100644 --- a/tests/cli/test_nodes.py +++ b/tests/cli/test_nodes.py @@ -18,7 +18,7 @@ import mock from aria.cli.env import _Environment -from .base_test import ( # pylint: disable=unused-import +from .base_test import ( # pylint: disable=unused-import TestCliBase, mock_storage ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index cc0150e..3c822a4 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -24,7 +24,7 @@ from aria.core import Core from aria.exceptions import AriaException from aria.storage import exceptions as storage_exceptions -from .base_test import ( # pylint: disable=unused-import +from .base_test import ( # pylint: disable=unused-import TestCliBase, assert_exception_raised, raise_exception, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/cli/test_services.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py index 7dc84bc..286a2c3 100644 --- a/tests/cli/test_services.py +++ b/tests/cli/test_services.py @@ -22,7 +22,7 @@ from aria.exceptions import DependentActiveExecutionsError, DependentAvailableNo from aria.modeling.exceptions import ParameterException from aria.storage import exceptions as storage_exceptions -from .base_test import ( # pylint: disable=unused-import +from .base_test import ( # pylint: disable=unused-import TestCliBase, raise_exception, assert_exception_raised, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/end2end/test_hello_world.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_hello_world.py b/tests/end2end/test_hello_world.py index eeb1781..d603992 100644 --- a/tests/end2end/test_hello_world.py +++ b/tests/end2end/test_hello_world.py @@ -15,7 +15,7 @@ import requests -from .testenv import testenv # pylint: disable=unused-import +from .testenv import testenv # pylint: disable=unused-import from .. import helpers http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/end2end/test_nodecellar.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_nodecellar.py b/tests/end2end/test_nodecellar.py index e8cfa84..2873040 100644 --- a/tests/end2end/test_nodecellar.py +++ b/tests/end2end/test_nodecellar.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .testenv import testenv # pylint: disable=unused-import +from .testenv import testenv # pylint: disable=unused-import from .. import helpers http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/mechanisms/web_server.py ---------------------------------------------------------------------- diff --git a/tests/mechanisms/web_server.py b/tests/mechanisms/web_server.py index 8a50ae7..8711cb4 100644 --- a/tests/mechanisms/web_server.py +++ b/tests/mechanisms/web_server.py @@ -75,7 +75,7 @@ class WebServer(threading.Thread): class TextHandler(tornado.web.RequestHandler): - def initialize(self, content, content_type): # pylint: disable=arguments-differ + def initialize(self, content, content_type): # pylint: disable=arguments-differ self.content = content self.content_type = content_type http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/mock/workflow.py ---------------------------------------------------------------------- diff --git a/tests/mock/workflow.py b/tests/mock/workflow.py index b12b9fa..74f63c2 100644 --- a/tests/mock/workflow.py +++ b/tests/mock/workflow.py @@ -19,7 +19,7 @@ from aria.orchestrator.decorators import workflow @workflow -def mock_workflow(graph, ctx, output_path=None, **kwargs): # pylint: disable=unused-argument +def mock_workflow(graph, ctx, output_path=None, **kwargs): # pylint: disable=unused-argument if output_path: # writes call arguments to the specified output file with open(output_path, 'w') as f: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/modeling/__init__.py ---------------------------------------------------------------------- diff --git a/tests/modeling/__init__.py b/tests/modeling/__init__.py index 072ef54..424252c 100644 --- a/tests/modeling/__init__.py +++ b/tests/modeling/__init__.py @@ -26,7 +26,7 @@ from aria.modeling import ( ) -class MockModel(models.aria_declarative_base, mixins.ModelMixin): #pylint: disable=abstract-method +class MockModel(models.aria_declarative_base, mixins.ModelMixin): # pylint: disable=abstract-method __tablename__ = 'mock_model' model_dict = Column(modeling_types.Dict) model_list = Column(modeling_types.List) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/context/test_operation.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index 111e121..ba33dc2 100644 --- a/tests/orchestrator/context/test_operation.py +++ b/tests/orchestrator/context/test_operation.py @@ -106,7 +106,7 @@ def test_node_operation_task_execution(ctx, thread_executor, dataholder): ) operations = interface.operations assert len(operations) == 1 - assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member + assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member assert dataholder['arguments']['putput'] is True # Context based attributes (sugaring) @@ -150,7 +150,7 @@ def test_relationship_operation_task_execution(ctx, thread_executor, dataholder) assert dataholder['actor_name'] == relationship.name assert interface_name in dataholder['task_name'] operations = interface.operations - assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member + assert dataholder['function'] == operations.values()[0].function # pylint: disable=no-member assert dataholder['arguments']['putput'] is True # Context based attributes (sugaring) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/context/test_serialize.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_serialize.py b/tests/orchestrator/context/test_serialize.py index 6e9c950..099515c 100644 --- a/tests/orchestrator/context/test_serialize.py +++ b/tests/orchestrator/context/test_serialize.py @@ -23,6 +23,7 @@ import tests from tests import mock from tests import storage + TEST_FILE_CONTENT = 'CONTENT' TEST_FILE_ENTRY_ID = 'entry' TEST_FILE_NAME = 'test_file' @@ -47,7 +48,7 @@ def test_serialize_operation_context(context, executor, tmpdir): node.interfaces[interface.name] = interface context.model.node.update(node) - graph = _mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter + graph = _mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter graph_compiler.GraphCompiler(context, executor.__class__).compile(graph) eng = engine.Engine(executor) eng.execute(context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/context/test_workflow.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_workflow.py b/tests/orchestrator/context/test_workflow.py index 6d53c2a..9869354 100644 --- a/tests/orchestrator/context/test_workflow.py +++ b/tests/orchestrator/context/test_workflow.py @@ -31,7 +31,7 @@ class TestWorkflowContext(object): def test_execution_creation_on_workflow_context_creation(self, storage): ctx = self._create_ctx(storage) - execution = storage.execution.get(ctx.execution.id) # pylint: disable=no-member + execution = storage.execution.get(ctx.execution.id) # pylint: disable=no-member assert execution.service == storage.service.get_by_name( mock.models.SERVICE_NAME) assert execution.workflow_name == mock.models.WORKFLOW_NAME http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/execution/test_execution_compiler.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/execution/test_execution_compiler.py b/tests/orchestrator/execution/test_execution_compiler.py index 42e5272..3d96852 100644 --- a/tests/orchestrator/execution/test_execution_compiler.py +++ b/tests/orchestrator/execution/test_execution_compiler.py @@ -38,13 +38,14 @@ from tests import ( storage ) -from ...fixtures import ( # pylint: disable=unused-import +from ...fixtures import ( # pylint: disable=unused-import plugins_dir, plugin_manager, fs_model as model, resource_storage as resource ) + custom_events = { 'is_resumed': Event(), 'is_active': Event(), http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/execution_plugin/test_local.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/execution_plugin/test_local.py b/tests/orchestrator/execution_plugin/test_local.py index 5af6a2f..539730a 100644 --- a/tests/orchestrator/execution_plugin/test_local.py +++ b/tests/orchestrator/execution_plugin/test_local.py @@ -499,7 +499,7 @@ if __name__ == '__main__': operation_name='op', arguments=arguments)) return graph - tasks_graph = mock_workflow(ctx=workflow_context) # pylint: disable=no-value-for-parameter + tasks_graph = mock_workflow(ctx=workflow_context) # pylint: disable=no-value-for-parameter graph_compiler.GraphCompiler(workflow_context, executor.__class__).compile(tasks_graph) eng = engine.Engine(executor) eng.execute(workflow_context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/execution_plugin/test_ssh.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/execution_plugin/test_ssh.py b/tests/orchestrator/execution_plugin/test_ssh.py index e39f3ba..f619bf7 100644 --- a/tests/orchestrator/execution_plugin/test_ssh.py +++ b/tests/orchestrator/execution_plugin/test_ssh.py @@ -260,7 +260,7 @@ class TestWithActualSSHServer(object): graph.sequence(*ops) return graph - tasks_graph = mock_workflow(ctx=self._workflow_context) # pylint: disable=no-value-for-parameter + tasks_graph = mock_workflow(ctx=self._workflow_context) # pylint: disable=no-value-for-parameter graph_compiler.GraphCompiler( self._workflow_context, self._executor.__class__).compile(tasks_graph) eng = engine.Engine(self._executor) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/workflows/executor/test_process_executor.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index e050d18..d801ffb 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -34,7 +34,7 @@ from aria.orchestrator.workflows.executor import process import tests.storage import tests.resources from tests.helpers import FilesystemDataHolder -from tests.fixtures import ( # pylint: disable=unused-import +from tests.fixtures import ( # pylint: disable=unused-import plugins_dir, plugin_manager, ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/workflows/executor/test_process_executor_extension.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/executor/test_process_executor_extension.py b/tests/orchestrator/workflows/executor/test_process_executor_extension.py index 0093976..7ab1ea5 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor_extension.py +++ b/tests/orchestrator/workflows/executor/test_process_executor_extension.py @@ -56,7 +56,7 @@ def test_decorate_extension(context, executor): arguments=arguments) graph.add_tasks(task) return graph - graph = mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter + graph = mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter graph_compiler.GraphCompiler(context, executor.__class__).compile(graph) eng = engine.Engine(executor) eng.execute(context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py b/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py index 8aaf4ef..b469e71 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py +++ b/tests/orchestrator/workflows/executor/test_process_executor_tracked_changes.py @@ -72,9 +72,9 @@ def test_apply_tracked_changes_during_an_operation(context, executor): context=context, executor=executor, op_func=_mock_updating_operation, arguments=arguments) expected_after_update = expected_initial.copy() - expected_after_update.update(arguments['committed']) # pylint: disable=no-member + expected_after_update.update(arguments['committed']) # pylint: disable=no-member expected_after_change = expected_after_update.copy() - expected_after_change.update(arguments['changed_but_refreshed']) # pylint: disable=no-member + expected_after_change.update(arguments['changed_but_refreshed']) # pylint: disable=no-member assert out['initial'] == expected_initial assert out['after_update'] == expected_after_update @@ -106,7 +106,7 @@ def _run_workflow(context, executor, op_func, arguments=None): arguments=wf_arguments) graph.add_tasks(task) return graph - graph = mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter + graph = mock_workflow(ctx=context) # pylint: disable=no-value-for-parameter graph_compiler.GraphCompiler(context, executor.__class__).compile(graph) eng = engine.Engine(executor) eng.execute(context) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/storage/test_model_storage.py ---------------------------------------------------------------------- diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py index 518d624..bc5434a 100644 --- a/tests/storage/test_model_storage.py +++ b/tests/storage/test_model_storage.py @@ -49,7 +49,7 @@ def storage(): @pytest.fixture(scope='module', autouse=True) def module_cleanup(): - modeling.models.aria_declarative_base.metadata.remove(tests_modeling.MockModel.__table__) #pylint: disable=no-member + modeling.models.aria_declarative_base.metadata.remove(tests_modeling.MockModel.__table__) # pylint: disable=no-member def test_storage_base(storage): @@ -162,7 +162,7 @@ def test_mapi_include(context): assert_include(service2) -class MockModel(modeling.models.aria_declarative_base, modeling.mixins.ModelMixin): #pylint: disable=abstract-method +class MockModel(modeling.models.aria_declarative_base, modeling.mixins.ModelMixin): # pylint: disable=abstract-method __tablename__ = 'op_mock_model' name = Column(Text) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/test_extension.py ---------------------------------------------------------------------- diff --git a/tests/test_extension.py b/tests/test_extension.py index f0378fd..247bbb6 100644 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=no-member,no-method-argument,unused-variable + import pytest from aria import extension -# #pylint: disable=no-member,no-method-argument,unused-variable - class TestRegistrar(object): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/utils/test_plugin.py ---------------------------------------------------------------------- diff --git a/tests/utils/test_plugin.py b/tests/utils/test_plugin.py index c91d0c9..452983b 100644 --- a/tests/utils/test_plugin.py +++ b/tests/utils/test_plugin.py @@ -20,7 +20,7 @@ import pytest from aria.orchestrator import exceptions from aria.utils.plugin import create as create_plugin -from ..fixtures import ( # pylint: disable=unused-import +from ..fixtures import ( # pylint: disable=unused-import plugins_dir, plugin_manager, inmemory_model as model http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/71cf541f/tests/utils/test_versions.py ---------------------------------------------------------------------- diff --git a/tests/utils/test_versions.py b/tests/utils/test_versions.py index bcbf9ef..1c05144 100644 --- a/tests/utils/test_versions.py +++ b/tests/utils/test_versions.py @@ -53,7 +53,7 @@ def test_version_string(): assert VersionString() == VersionString() assert VersionString() == VersionString.NULL assert VersionString(None) == VersionString.NULL - assert VersionString.NULL == None # pylint: disable=singleton-comparison + assert VersionString.NULL == None # pylint: disable=singleton-comparison assert VersionString.NULL == 0 # Invalid version strings
