add async method test case for pet api;

This commit is contained in:
zhenjun115
2016-06-19 12:31:10 +08:00
parent 67c3f98d96
commit 86c8647ace
3 changed files with 30 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +0,0 @@
Collecting nose (from -r dev-requirements.txt (line 1))
Downloading nose-1.3.7-py2-none-any.whl (154kB)
Collecting tox (from -r dev-requirements.txt (line 2))
Downloading tox-2.3.1-py2.py3-none-any.whl (40kB)
Collecting coverage (from -r dev-requirements.txt (line 3))
Downloading coverage-4.1-cp27-cp27m-macosx_10_10_x86_64.whl (164kB)
Collecting randomize (from -r dev-requirements.txt (line 4))
Downloading randomize-0.13-py2.py3-none-any.whl
Collecting virtualenv>=1.11.2 (from tox->-r dev-requirements.txt (line 2))
Downloading virtualenv-15.0.2-py2.py3-none-any.whl (1.8MB)
Collecting py>=1.4.17 (from tox->-r dev-requirements.txt (line 2))
Downloading py-1.4.31-py2.py3-none-any.whl (81kB)
Collecting pluggy<0.4.0,>=0.3.0 (from tox->-r dev-requirements.txt (line 2))
Downloading pluggy-0.3.1-py2.py3-none-any.whl
Installing collected packages: nose, virtualenv, py, pluggy, tox, coverage, randomize
Successfully installed coverage-4.1 nose-1.3.7 pluggy-0.3.1 py-1.4.31 randomize-0.13 tox-2.3.1 virtualenv-15.0.2

View File

@@ -97,6 +97,21 @@ class PetApiTests(unittest.TestCase):
self.assertIsNotNone(fetched.category)
self.assertEqual(self.pet.category.name, fetched.category.name)
def test_async_add_pet_and_get_pet_by_id(self):
self.pet_api.add_pet(body=self.pet)
def callback_function(data):
#fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id)
self.assertIsNotNone(data)
self.assertEqual(self.pet.id, data.id)
self.assertIsNotNone(data.category)
self.assertEqual(self.pet.category.name, data.category.name)
thread = self.pet_api.get_pet_by_id(pet_id=self.pet.id, callback=callback_function)
thread.join(10)
if thread.isAlive():
self.fail("Request timeout")
def test_add_pet_and_get_pet_by_id_with_http_info(self):
self.pet_api.add_pet(body=self.pet)
@@ -106,6 +121,21 @@ class PetApiTests(unittest.TestCase):
self.assertIsNotNone(fetched[0].category)
self.assertEqual(self.pet.category.name, fetched[0].category.name)
def test_async_add_pet_and_get_pet_by_id_with_http_info(self):
self.pet_api.add_pet(body=self.pet)
def callback_function(data):
#fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id)
self.assertIsNotNone(data)
self.assertEqual(self.pet.id, data.id)
self.assertIsNotNone(data.category)
self.assertEqual(self.pet.category.name, data.category.name)
thread = self.pet_api.get_pet_by_id(pet_id=self.pet.id, callback=callback_function)
thread.join(10)
if thread.isAlive():
self.fail("Request timeout")
def test_update_pet(self):
self.pet.name = "hello kity with updated"
self.pet_api.update_pet(body=self.pet)