update test
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e16a2b06 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e16a2b06 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e16a2b06 Branch: refs/heads/trunk Commit: e16a2b06075f115eb80a6781d6f64f00104fc521 Parents: e459ef6 Author: andy <[email protected]> Authored: Sun Jun 18 11:51:12 2017 -0400 Committer: andy <[email protected]> Committed: Sun Jun 18 11:51:12 2017 -0400 ---------------------------------------------------------------------- libcloud/container/drivers/gke.py | 9 +++++++-- libcloud/test/container/test_gke.py | 30 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e16a2b06/libcloud/container/drivers/gke.py ---------------------------------------------------------------------- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 91f24da..acac294 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -145,6 +145,9 @@ class GKEContainerDriver(KubernetesContainerDriver): self.auth_type = auth_type self.project = project self.scopes = scopes + self.zone = None + if datacenter is not None: + self.zone = datacenter self.credential_file = credential_file or \ GoogleOAuth2Credential.default_credential_file + '.' + self.project @@ -161,7 +164,7 @@ class GKEContainerDriver(KubernetesContainerDriver): 'scopes': self.scopes, 'credential_file': self.credential_file} - def list_clusters(self, zone=None): + def list_images(self, zone=None): """ """ request = "/zones/%s/clusters" % (zone) @@ -174,7 +177,9 @@ class GKEContainerDriver(KubernetesContainerDriver): def get_server_config(self, zone=None): """ """ - request = "/zones/%s/serverconfig" % (zone) + if zone is None: + zone = self.zone + request = "/zones/%s/serverconfig" % (self.zone) response = self.connection.request(request, method='GET').object return response http://git-wip-us.apache.org/repos/asf/libcloud/blob/e16a2b06/libcloud/test/container/test_gke.py ---------------------------------------------------------------------- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index f38e5f5..98ea1f3 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -22,11 +22,7 @@ import sys import unittest from libcloud.utils.py3 import httplib -from libcloud.compute.drivers.gce import ( - GCENodeDriver, API_VERSION, timestamp_to_datetime, GCEAddress, GCEBackend, - GCEBackendService, GCEFirewall, GCEForwardingRule, GCEHealthCheck, - GCENetwork, GCENodeImage, GCERoute, GCERegion, GCETargetHttpProxy, - GCEUrlMap, GCEZone, GCESubnetwork) +from libcloud.container.drivers.gke import GKEContainerDriver, API_VERSION from libcloud.common.google import (GoogleBaseAuthConnection, ResourceNotFoundError, ResourceExistsError, GoogleBaseError) @@ -34,7 +30,7 @@ from libcloud.test.common.test_google import GoogleAuthMockHttp, GoogleTestCase from libcloud.compute.base import Node, StorageVolume from libcloud.test import MockHttp -from libcloud.test.compute import TestCaseMixin +from libcloud.test.container import TestCaseMixin from libcloud.test.file_fixtures import ContainerFileFixtures from libcloud.test.secrets import GKE_PARAMS, GKE_KEYWORD_PARAMS @@ -46,29 +42,29 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): """ # Mock out a few specific calls that interact with the user, system or # environment. - GCEZone._now = lambda x: datetime.datetime(2013, 6, 26, 19, 0, 0) datacenter = 'us-central1-a' def setUp(self): GKEMockHttp.test = self - GKEContainerDriver.connectionCls.conn_class = GCEMockHttp + GKEContainerDriver.connectionCls.conn_class = GKEMockHttp GoogleBaseAuthConnection.conn_class = GoogleAuthMockHttp GKEMockHttp.type = None - kwargs = GCE_KEYWORD_PARAMS.copy() + kwargs = GKE_KEYWORD_PARAMS.copy() kwargs['auth_type'] = 'IA' kwargs['datacenter'] = self.datacenter - self.driver = GCENodeDriver(*GCE_PARAMS, **kwargs) + self.driver = GKEContainerDriver(*GKE_PARAMS, **kwargs) - def test_default_scopes(self): - self.assertEqual(self.driver.scopes, None) + def test_list_images_response(self): + pass -class GCEMockHttp(MockHttp): - fixtures = ContainerFileFixtures('gce') +class GKEMockHttp(MockHttp): + fixtures = ContainerFileFixtures('gke') json_hdr = {'content-type': 'application/json; charset=UTF-8'} def _get_method_name(self, type, use_param, qs, path): - api_path = '/container/%s' % API_VERSION + print("GKEMOCKHTTP", type, use_param, qs, path) + api_path = '%s' % API_VERSION project_path = '/projects/%s' % GKE_KEYWORD_PARAMS['project'] path = path.replace(api_path, '') # This replace is separate, since there is a call with a different @@ -76,8 +72,12 @@ class GCEMockHttp(MockHttp): path = path.replace(project_path, '') # The path to get project information is the base path, so use a fake # '/project' path instead + print("path", path) if not path: path = '/project' method_name = super(GKEMockHttp, self)._get_method_name( type, use_param, qs, path) return method_name + +if __name__ == '__main__': + sys.exit(unittest.main())
