From 89dd01e4a0fcea7cadd6624697f1651d15b81fd4 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Fri, 27 Mar 2015 20:39:31 +0000 Subject: [PATCH] Run svc-map tests We currently do not run these tests and they also fail. Change-Id: I60c8cbd9495b52fb8b4c848549822a05f921664f --- .../extra-data.d/10-merge-svc-map-files | 3 ++- elements/svc-map/tests/__init__.py | 0 elements/svc-map/tests/test_data_merge.py | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 elements/svc-map/tests/__init__.py diff --git a/elements/svc-map/extra-data.d/10-merge-svc-map-files b/elements/svc-map/extra-data.d/10-merge-svc-map-files index 9a7510be7..3aa1afe29 100755 --- a/elements/svc-map/extra-data.d/10-merge-svc-map-files +++ b/elements/svc-map/extra-data.d/10-merge-svc-map-files @@ -15,6 +15,7 @@ import os import sys +import six import yaml @@ -38,7 +39,7 @@ def merge_data(source, destination, distro): result = dict() result.update(destination) family = os_family(distro) - for servicename, mapping in source.iteritems(): + for servicename, mapping in six.iteritems(source): if servicename in result: raise Exception("%s already found in services list" % servicename) if distro in mapping: diff --git a/elements/svc-map/tests/__init__.py b/elements/svc-map/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/elements/svc-map/tests/test_data_merge.py b/elements/svc-map/tests/test_data_merge.py index 7074bfeca..5356ae0be 100644 --- a/elements/svc-map/tests/test_data_merge.py +++ b/elements/svc-map/tests/test_data_merge.py @@ -12,8 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. import imp -service_map = imp.load_source('service_map', - '../extra-data.d/10-merge-svc-map-files') +import os + +module_path = (os.path.dirname(os.path.realpath(__file__)) + + '/../extra-data.d/10-merge-svc-map-files') +service_map = imp.load_source('service_map', module_path) from oslotest import base @@ -98,7 +101,7 @@ class TestDataMerge(base.BaseTestCase): } result = dict() - result = service_map.merge_json(self.nova_api_services, + result = service_map.merge_data(self.nova_api_services, result, "fedora") @@ -106,7 +109,7 @@ class TestDataMerge(base.BaseTestCase): fedora_nova_api_services, "Merge failed") - result = service_map.merge_json(self.glance_api_services, + result = service_map.merge_data(self.glance_api_services, result, "fedora") @@ -114,7 +117,7 @@ class TestDataMerge(base.BaseTestCase): fedora_nova_glance_services, "Merge failed") - result = service_map.merge_json(self.cinder_api_services, + result = service_map.merge_data(self.cinder_api_services, result, "fedora") self.assertDictEqual(result, @@ -154,7 +157,7 @@ class TestDataMerge(base.BaseTestCase): } result = dict() - result = service_map.merge_json(self.nova_api_services, + result = service_map.merge_data(self.nova_api_services, result, "ubuntu") @@ -162,7 +165,7 @@ class TestDataMerge(base.BaseTestCase): ubuntu_nova_api_services, "Merge failed") - result = service_map.merge_json(self.glance_api_services, + result = service_map.merge_data(self.glance_api_services, result, "ubuntu") @@ -170,7 +173,7 @@ class TestDataMerge(base.BaseTestCase): ubuntu_nova_glance_services, "Merge failed") - result = service_map.merge_json(self.cinder_api_services, + result = service_map.merge_data(self.cinder_api_services, result, "ubuntu")