From e9a0251253758d7821eba0ec396883536994cbb2 Mon Sep 17 00:00:00 2001 From: xiulin yin Date: Tue, 14 Feb 2017 17:51:09 +0800 Subject: [PATCH] Add get pod unit test case 1. What is the problem Tricircle does not have get pod unit test case 2. What is the solution to the problem Implement related test case 3. What the features need to be implemented to the Tricircle No new features Change-Id: Icf68127871d3c3393f43d54ee0a853215c6bad2f --- tricircle/db/api.py | 5 ----- tricircle/tests/unit/db/test_api.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tricircle/db/api.py b/tricircle/db/api.py index 66e198f0..f0243991 100644 --- a/tricircle/db/api.py +++ b/tricircle/db/api.py @@ -64,11 +64,6 @@ def update_pod(context, pod_id, update_dict): return core.update_resource(context, models.Pod, pod_id, update_dict) -def get_pod_by_pod_id(context, pod_id): - with context.session.begin(): - return core.get_resource(context, models.Pod, pod_id) - - def create_cached_endpoints(context, config_dict): with context.session.begin(): return core.create_resource(context, models.CachedEndpoint, diff --git a/tricircle/tests/unit/db/test_api.py b/tricircle/tests/unit/db/test_api.py index b2c4e989..851dd83e 100644 --- a/tricircle/tests/unit/db/test_api.py +++ b/tricircle/tests/unit/db/test_api.py @@ -256,6 +256,19 @@ class APITest(unittest.TestCase): pod = api.get_pod_by_name(self.context, region_name) self.assertEqual(pod['region_name'], region_name) + def test_get_pod(self): + self._create_pod(0, 'test_az_uuid1') + self._create_pod(1, 'test_az_uuid1') + self._create_pod(2, 'test_az_uuid2') + + pod_id = 'test_pod_uuid_0' + pod = api.get_pod(self.context, pod_id) + self.assertEqual(pod['pod_id'], pod_id) + + pod_id = 'test_pod_uuid_3' + self.assertRaises( + exceptions.ResourceNotFound, api.get_pod, self.context, pod_id) + def test_delete_mappings_by_bottom_id(self): self._create_pod(0, 'test_az_uuid_0') self._create_pod(1, 'test_az_uuid_1')