Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-157-cli-service-template-store-tests-fail-in-windows [created] ca49ae016
ARIA-157 Failing CLI service-templates store tests on Windows Three tests from `aria service-templates store` failed on Windows, but not on Linux. The reason for this failures was differing implementation of os.path.dirname across the platfroms. Python implements os.path.dirname in the ntpath module. There, somewhere down the line of calls, (a part of) the argument of dirname is tested for membership in a string (using `in`). In these three tests, the argument of dirname is of type MagicMock, and an error is raised since only a string can be tested for memebership in a string. The solution was to mock the dirname calls. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ca49ae01 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ca49ae01 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ca49ae01 Branch: refs/heads/ARIA-157-cli-service-template-store-tests-fail-in-windows Commit: ca49ae016962a260e0363522482e453b18db024f Parents: 0af9e63 Author: Avia Efrat <[email protected]> Authored: Wed May 10 17:39:49 2017 +0300 Committer: Avia Efrat <[email protected]> Committed: Wed May 10 17:39:49 2017 +0300 ---------------------------------------------------------------------- tests/cli/test_service_templates.py | 3 +++ 1 file changed, 3 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ca49ae01/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index 22a8fc8..bc3c751 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -128,6 +128,7 @@ class TestServiceTemplatesStore(TestCliBase): monkeypatch.setattr(Core, 'create_service_template', mock_object) monkeypatch.setattr(service_template_utils, 'get', mock_object) + monkeypatch.setattr(os.path, 'dirname', mock_object) self.invoke('service_templates store stubpath {name}'.format( name=mock_models.SERVICE_TEMPLATE_NAME)) assert 'Service template {name} stored'.format( @@ -152,6 +153,7 @@ class TestServiceTemplatesStore(TestCliBase): 'create_service_template', raise_exception(storage_exceptions.NotFoundError, msg='UNIQUE constraint failed')) + monkeypatch.setattr(os.path, 'dirname', mock_object) assert_exception_raised( self.invoke('service_templates store stubpath test_st'), @@ -164,6 +166,7 @@ class TestServiceTemplatesStore(TestCliBase): monkeypatch.setattr(Core, 'create_service_template', raise_exception(storage_exceptions.NotFoundError)) + monkeypatch.setattr(os.path, 'dirname', mock_object) assert_exception_raised( self.invoke('service_templates store stubpath test_st'),
