forked from loafle/openapi-generator-original
added test case for 404 response of python client
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Credit: this file (rest.py) is modified based on rest.py in Dropbox Python SDK:
|
||||
https://www.dropbox.com/developers/core/sdks/python
|
||||
"""
|
||||
|
||||
import sys
|
||||
import io
|
||||
import json
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Run the tests.
|
||||
$ pip install nose (optional)
|
||||
$ cd SwaggerPetstore-python
|
||||
$ nosetests -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import SwaggerPetstore
|
||||
from SwaggerPetstore.rest import ApiException
|
||||
|
||||
|
||||
class ApiExceptionTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.api_client = SwaggerPetstore.ApiClient()
|
||||
self.pet_api = SwaggerPetstore.PetApi(self.api_client)
|
||||
|
||||
def tearDown(self):
|
||||
time.sleep(1)
|
||||
|
||||
def test_404_error(self):
|
||||
self.pet_api.delete_pet(pet_id=1234)
|
||||
|
||||
with self.assertRaisesRegexp(ApiException, "Pet not found"):
|
||||
self.pet_api.get_pet_by_id(pet_id=1234)
|
||||
Reference in New Issue
Block a user