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

Side by Side Diff: third_party/google-endpoints/apitools/gen/gen_client_test.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 #
2 # Copyright 2015 Google Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 """Test for gen_client module."""
17
18 import os
19
20 import unittest2
21
22 from apitools.gen import gen_client
23 from apitools.gen import test_utils
24
25
26 def GetDocPath(name):
27 return os.path.join(os.path.dirname(__file__), 'testdata', name)
28
29
30 @test_utils.RunOnlyOnPython27
31 class ClientGenCliTest(unittest2.TestCase):
32
33 def testHelp_NotEnoughArguments(self):
34 with self.assertRaisesRegexp(SystemExit, '0'):
35 with test_utils.CaptureOutput() as (_, err):
36 gen_client.main([gen_client.__file__, '-h'])
37 err_output = err.getvalue()
38 self.assertIn('usage:', err_output)
39 self.assertIn('error: too few arguments', err_output)
40
41 def testGenClient_SimpleDoc(self):
42 with test_utils.TempDir() as tmp_dir_path:
43 gen_client.main([
44 gen_client.__file__,
45 '--nogenerate_cli',
46 '--infile', GetDocPath('dns_v1.json'),
47 '--outdir', tmp_dir_path,
48 '--overwrite',
49 '--root_package', 'google.apis',
50 'client'
51 ])
52 self.assertEquals(
53 set(['dns_v1_client.py', 'dns_v1_messages.py', '__init__.py']),
54 set(os.listdir(tmp_dir_path)))
55
56 def testGenClient_SimpleDocWithV4(self):
57 with test_utils.TempDir() as tmp_dir_path:
58 gen_client.main([
59 gen_client.__file__,
60 '--nogenerate_cli',
61 '--infile', GetDocPath('dns_v1.json'),
62 '--outdir', tmp_dir_path,
63 '--overwrite',
64 '--apitools_version', '0.4.12',
65 '--root_package', 'google.apis',
66 'client'
67 ])
68 self.assertEquals(
69 set(['dns_v1_client.py', 'dns_v1_messages.py', '__init__.py']),
70 set(os.listdir(tmp_dir_path)))
71
72 def testGenClient_SimpleDocWithV5(self):
73 with test_utils.TempDir() as tmp_dir_path:
74 gen_client.main([
75 gen_client.__file__,
76 '--nogenerate_cli',
77 '--infile', GetDocPath('dns_v1.json'),
78 '--outdir', tmp_dir_path,
79 '--overwrite',
80 '--apitools_version', '0.5.0',
81 '--root_package', 'google.apis',
82 'client'
83 ])
84 self.assertEquals(
85 set(['dns_v1_client.py', 'dns_v1_messages.py', '__init__.py']),
86 set(os.listdir(tmp_dir_path)))
87
88 def testGenPipPackage_SimpleDoc(self):
89 with test_utils.TempDir() as tmp_dir_path:
90 gen_client.main([
91 gen_client.__file__,
92 '--nogenerate_cli',
93 '--infile', GetDocPath('dns_v1.json'),
94 '--outdir', tmp_dir_path,
95 '--overwrite',
96 '--root_package', 'google.apis',
97 'pip_package'
98 ])
99 self.assertEquals(
100 set(['apitools', 'setup.py']),
101 set(os.listdir(tmp_dir_path)))
102
103 def testGenProto_SimpleDoc(self):
104 with test_utils.TempDir() as tmp_dir_path:
105 gen_client.main([
106 gen_client.__file__,
107 '--nogenerate_cli',
108 '--infile', GetDocPath('dns_v1.json'),
109 '--outdir', tmp_dir_path,
110 '--overwrite',
111 '--root_package', 'google.apis',
112 'proto'
113 ])
114 self.assertEquals(
115 set(['dns_v1_messages.proto', 'dns_v1_services.proto']),
116 set(os.listdir(tmp_dir_path)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698