Add test cases for StoreApi#get_inventory

This commit is contained in:
xhh 2015-06-12 23:03:17 +08:00
parent 36f0ed6d0c
commit 80616b4c2b
2 changed files with 25 additions and 6 deletions

View File

@ -13,9 +13,14 @@ describe "Pet" do
tag2 = SwaggerClient::Tag.new({'id' => 2, 'name'=> 'tag2'})
category1 = SwaggerClient::Category.new({:id => 1, :name => 'category unknown'})
# initalize using both string and symbol key
pet_hash = {:'id' => 10002, :'name' => "RUBY UNIT TESTING", :'status' => "pending",
:'photo_urls' => ["url1", "url2"], :'category' => category1,
:'tags' => [tag1, tag2]}
pet_hash = {
:id => 10002,
:name => "RUBY UNIT TESTING",
:status => "pending",
:photo_urls => ["url1", "url2"],
:category => category1,
:tags => [tag1, tag2]
}
pet = SwaggerClient::Pet.new(pet_hash)
# test new
pet.name.should == "RUBY UNIT TESTING"
@ -48,6 +53,10 @@ describe "Pet" do
it "should find pets by status" do
pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'available')
pets.length.should >= 3
pets.each do |pet|
pet.should be_a(SwaggerClient::Pet)
pet.status.should == 'available'
end
end
it "should not find a pet with invalid status" do
@ -57,11 +66,11 @@ describe "Pet" do
it "should find a pet by status" do
pets = SwaggerClient::PetApi.find_pets_by_status(:status => "available,sold")
pets.map {|pet|
if(pet.status != 'available' && pet.status != 'sold')
pets.each do |pet|
if pet.status != 'available' && pet.status != 'sold'
raise "pet status wasn't right"
end
}
end
end
it "should update a pet" do

View File

@ -10,4 +10,14 @@ describe "Store" do
item = SwaggerClient::StoreApi.get_order_by_id(10002)
item.id.should == 10002
end
it "should featch the inventory" do
result = SwaggerClient::StoreApi.get_inventory
result.should be_a(Hash)
result.should_not be_empty
result.each do |k, v|
k.should be_a(Symbol)
v.should be_a(Integer)
end
end
end