@@ -164,6 +164,27 @@ def test_spec_from_local(self):
164
164
self .assertEqual (set ([n .name for n in context .root .children ]),
165
165
set (['users' , 'orgs' ]))
166
166
167
+ def test_spec_basePath (self ):
168
+ spec_filepath = self .make_tempfile (json .dumps ({
169
+ 'basePath' : '/api/v1' ,
170
+ 'paths' : {
171
+ '/users' : {},
172
+ '/orgs' : {}
173
+ }
174
+ }))
175
+ result , context = run_and_exit (['example.com' , "--spec" ,
176
+ spec_filepath ])
177
+ self .assertEqual (result .exit_code , 0 )
178
+ self .assertEqual (context .url , 'http://example.com' )
179
+
180
+ lv1_names = set ([node .name for node in context .root .ls ()])
181
+ lv2_names = set ([node .name for node in context .root .ls ('api' )])
182
+ lv3_names = set ([node .name for node in context .root .ls ('api' , 'v1' )])
183
+
184
+ self .assertEqual (lv1_names , set (['api' ]))
185
+ self .assertEqual (lv2_names , set (['v1' ]))
186
+ self .assertEqual (lv3_names , set (['users' , 'orgs' ]))
187
+
167
188
def test_spec_from_http (self ):
168
189
spec_url = 'https://api.apis.guru/v2/specs/github.com/v3/swagger.json'
169
190
result , context = run_and_exit (['https://api.github.com' , '--spec' ,
@@ -175,6 +196,19 @@ def test_spec_from_http(self):
175
196
self .assertIn ('repos' , top_level_paths )
176
197
self .assertIn ('users' , top_level_paths )
177
198
199
+ def test_spec_from_http_only (self ):
200
+ spec_url = (
201
+ 'https://api.apis.guru/v2/specs/medium.com/1.0.0/swagger.json' )
202
+ result , context = run_and_exit (['--spec' , spec_url ])
203
+ self .assertEqual (result .exit_code , 0 )
204
+ self .assertEqual (context .url , 'https://api.medium.com/v1' )
205
+
206
+ lv1_names = set ([node .name for node in context .root .ls ()])
207
+ lv2_names = set ([node .name for node in context .root .ls ('v1' )])
208
+
209
+ self .assertEqual (lv1_names , set (['v1' ]))
210
+ self .assertEqual (lv2_names , set (['me' , 'publications' , 'users' ]))
211
+
178
212
def test_env_only (self ):
179
213
env_filepath = self .make_tempfile (
180
214
"cd http://example.com\n name=bob\n id==10" )
0 commit comments