added test case for 404 response of python client

This commit is contained in:
geekerzp
2015-06-03 10:46:32 +08:00
parent fbe327ac2f
commit 5fbda0e206
2 changed files with 37 additions and 0 deletions

View File

@@ -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

View File

@@ -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)