libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [02/20] libcloud git commit: reimplement get_container and remove unreachable test methods
Date Fri, 05 May 2017 11:46:21 GMT
reimplement get_container and remove unreachable test methods


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/40845d4f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/40845d4f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/40845d4f

Branch: refs/heads/trunk
Commit: 40845d4f970d22cf46970d2edff2bcd7a653322b
Parents: c99b6bc
Author: Anthony Shaw <anthonyshaw@apache.org>
Authored: Fri May 5 15:16:02 2017 +1000
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Fri May 5 15:16:02 2017 +1000

----------------------------------------------------------------------
 libcloud/container/drivers/kubernetes.py   |  9 +++------
 libcloud/test/container/test_kubernetes.py | 22 ++++------------------
 2 files changed, 7 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/40845d4f/libcloud/container/drivers/kubernetes.py
----------------------------------------------------------------------
diff --git a/libcloud/container/drivers/kubernetes.py b/libcloud/container/drivers/kubernetes.py
index d78fdd2..92036be 100644
--- a/libcloud/container/drivers/kubernetes.py
+++ b/libcloud/container/drivers/kubernetes.py
@@ -182,12 +182,9 @@ class KubernetesContainerDriver(ContainerDriver):
 
         :rtype: :class:`libcloud.container.base.Container`
         """
-        # result = self.connection.request(ROOT_URL + "v1/nodes/%s" %
-        #                                  id).object
-
-        # TODO: Fixme
-        # return self._to_container(result)
-        return None
+        containers = self.list_containers()
+        match = [container for container in containers if container.id == id]
+        return match[0]
 
     def list_clusters(self):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/40845d4f/libcloud/test/container/test_kubernetes.py
----------------------------------------------------------------------
diff --git a/libcloud/test/container/test_kubernetes.py b/libcloud/test/container/test_kubernetes.py
index f9d4c6d..b00af02 100644
--- a/libcloud/test/container/test_kubernetes.py
+++ b/libcloud/test/container/test_kubernetes.py
@@ -77,6 +77,10 @@ class KubernetesContainerDriverTestCase(unittest.TestCase):
         container = self.driver.deploy_container('hello-world', image=image)
         self.assertEqual(container.name, 'hello-world')
 
+    def test_get_container(self):
+        container = self.driver.get_container('docker://3c48b5cda79bce4c8866f02a3b96a024edb8f660d10e7d1755e9ced49ef47b36')
+        assert container.id == 'docker://3c48b5cda79bce4c8866f02a3b96a024edb8f660d10e7d1755e9ced49ef47b36'
+
 
 class KubernetesMockHttp(MockHttp):
     fixtures = ContainerFileFixtures('kubernetes')
@@ -89,30 +93,12 @@ class KubernetesMockHttp(MockHttp):
             raise AssertionError('Unsupported method')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
-    def _api_v1_nodes(
-            self, method, url, body, headers):
-        if method == 'GET':
-            body = self.fixtures.load('_api_v1_nodes.json')
-        else:
-            raise AssertionError('Unsupported method')
-        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
-    def _api_v1_nodes_127_0_0_1(
-            self, method, url, body, headers):
-        if method == 'GET':
-            body = self.fixtures.load('_api_v1_nodes_127_0_0_1.json')
-        else:
-            raise AssertionError('Unsupported method')
-        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
-
     def _api_v1_namespaces(
             self, method, url, body, headers):
         if method == 'GET':
             body = self.fixtures.load('_api_v1_namespaces.json')
         elif method == 'POST':
             body = self.fixtures.load('_api_v1_namespaces_test.json')
-        elif method == 'DELETE':
-            body = self.fixtures.load('_api_v1_namespaces_DELETE.json')
         else:
             raise AssertionError('Unsupported method')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])


Mime
View raw message