|
11 | 11 | from django.conf import settings |
12 | 12 | from django.contrib import messages |
13 | 13 | from django.contrib.auth.mixins import LoginRequiredMixin |
14 | | -from django.core.exceptions import PermissionDenied |
15 | | -from django.http import JsonResponse |
| 14 | +from django.core.exceptions import PermissionDenied |
| 15 | +from django.http import JsonResponse, HttpResponse |
16 | 16 | from django.urls import reverse_lazy, reverse |
17 | 17 | from django.views.generic import TemplateView |
18 | 18 | from django.views.generic.edit import CreateView, UpdateView, DeleteView |
|
22 | 22 | from .forms import TestConfigurationForm |
23 | 23 | from .models import TestConfiguration, ProfileOperation |
24 | 24 |
|
| 25 | + |
| 26 | + |
25 | 27 | LOGGER = logging.getLogger(__name__) |
26 | 28 | # TODO: These have to map to attributes of models.TestConfiguration |
27 | 29 | URLPATH_DEFAULT = [ |
@@ -352,8 +354,26 @@ def get_success_url(self): |
352 | 354 | testconfig = self.get_testconfigs(self.object.pk)['selected'] |
353 | 355 | self.api = API(self.request.session.get('obp')) |
354 | 356 | api_version = testconfig.api_version |
| 357 | + print ("api_version is {}".format(api_version)) |
355 | 358 | swagger = self.api.get_swagger(api_version) |
356 | | - for path, data in swagger['paths'].items(): |
| 359 | + print("the swagger is {}".format(swagger)) |
| 360 | + |
| 361 | + |
| 362 | + # Within successful response we expect there to be paths |
| 363 | + try: |
| 364 | + swagger_paths_items = swagger['paths'].items() |
| 365 | + except KeyError as err: |
| 366 | + # We probably can extract the reason from the response("swagger") |
| 367 | + response_code = swagger['code'] |
| 368 | + message = swagger['message'] |
| 369 | + # TODO Return this information calmly rather than as an exception. |
| 370 | + raise Exception(str(response_code) + " " + str(message)) |
| 371 | + |
| 372 | + #return JsonResponse({'code': str(response_code), 'message': str(message)}, safe=True) |
| 373 | + #return reverse('runtests-index-testconfig', kwargs={}) |
| 374 | + |
| 375 | + # Continue extracting the endpoints from the swagger json |
| 376 | + for path, data in swagger_paths_items: |
357 | 377 | for method, content in data.items(): |
358 | 378 | urlpath = path |
359 | 379 | remark = content['summary'] |
|
0 commit comments