Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: third_party/google-endpoints/apitools/gen/client_generation_test.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/google-endpoints/apitools/gen/client_generation_test.py
diff --git a/third_party/google-endpoints/apitools/gen/client_generation_test.py b/third_party/google-endpoints/apitools/gen/client_generation_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..cb0a9c4ed396e6dd6dfb8e1e19db30c0bd22453a
--- /dev/null
+++ b/third_party/google-endpoints/apitools/gen/client_generation_test.py
@@ -0,0 +1,79 @@
+#
+# Copyright 2015 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Test gen_client against all the APIs we use regularly."""
+
+import logging
+import os
+import subprocess
+import tempfile
+
+import unittest2
+
+from apitools.gen import test_utils
+
+
+_API_LIST = [
+ 'drive.v2',
+ 'bigquery.v2',
+ 'compute.v1',
+ 'storage.v1',
+]
+
+
+class ClientGenerationTest(unittest2.TestCase):
+
+ def setUp(self):
+ super(ClientGenerationTest, self).setUp()
+ self.gen_client_binary = 'gen_client'
+
+ @test_utils.RunOnlyOnPython27
+ def testGeneration(self):
+ for api in _API_LIST:
+ with test_utils.TempDir(change_to=True):
+ args = [
+ self.gen_client_binary,
+ '--client_id=12345',
+ '--client_secret=67890',
+ '--discovery_url=%s' % api,
+ '--outdir=generated',
+ '--overwrite',
+ 'client',
+ ]
+ logging.info('Testing API %s with command line: %s',
+ api, ' '.join(args))
+ retcode = subprocess.call(args)
+ if retcode == 128:
+ logging.error('Failed to fetch discovery doc, continuing.')
+ continue
+ self.assertEqual(0, retcode)
+
+ with tempfile.NamedTemporaryFile() as out:
+ with tempfile.NamedTemporaryFile() as err:
+ cmdline_args = [
+ os.path.join(
+ 'generated', api.replace('.', '_') + '.py'),
+ 'help',
+ ]
+ retcode = subprocess.call(
+ cmdline_args, stdout=out, stderr=err)
+ with open(err.name, 'rb') as f:
+ err_output = f.read()
+ # appcommands returns 1 on help
+ self.assertEqual(1, retcode)
+ if 'Traceback (most recent call last):' in err_output:
+ err = '\n======\n%s======\n' % err_output
+ self.fail(
+ 'Error raised in generated client:' + err)
« no previous file with comments | « third_party/google-endpoints/apitools/gen/__init__.py ('k') | third_party/google-endpoints/apitools/gen/command_registry.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698