forked from loafle/openapi-generator-original
Add test cases for StoreApi#get_inventory
This commit is contained in:
parent
36f0ed6d0c
commit
80616b4c2b
@ -13,9 +13,14 @@ describe "Pet" do
|
|||||||
tag2 = SwaggerClient::Tag.new({'id' => 2, 'name'=> 'tag2'})
|
tag2 = SwaggerClient::Tag.new({'id' => 2, 'name'=> 'tag2'})
|
||||||
category1 = SwaggerClient::Category.new({:id => 1, :name => 'category unknown'})
|
category1 = SwaggerClient::Category.new({:id => 1, :name => 'category unknown'})
|
||||||
# initalize using both string and symbol key
|
# initalize using both string and symbol key
|
||||||
pet_hash = {:'id' => 10002, :'name' => "RUBY UNIT TESTING", :'status' => "pending",
|
pet_hash = {
|
||||||
:'photo_urls' => ["url1", "url2"], :'category' => category1,
|
:id => 10002,
|
||||||
:'tags' => [tag1, tag2]}
|
:name => "RUBY UNIT TESTING",
|
||||||
|
:status => "pending",
|
||||||
|
:photo_urls => ["url1", "url2"],
|
||||||
|
:category => category1,
|
||||||
|
:tags => [tag1, tag2]
|
||||||
|
}
|
||||||
pet = SwaggerClient::Pet.new(pet_hash)
|
pet = SwaggerClient::Pet.new(pet_hash)
|
||||||
# test new
|
# test new
|
||||||
pet.name.should == "RUBY UNIT TESTING"
|
pet.name.should == "RUBY UNIT TESTING"
|
||||||
@ -48,6 +53,10 @@ describe "Pet" do
|
|||||||
it "should find pets by status" do
|
it "should find pets by status" do
|
||||||
pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'available')
|
pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'available')
|
||||||
pets.length.should >= 3
|
pets.length.should >= 3
|
||||||
|
pets.each do |pet|
|
||||||
|
pet.should be_a(SwaggerClient::Pet)
|
||||||
|
pet.status.should == 'available'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not find a pet with invalid status" do
|
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
|
it "should find a pet by status" do
|
||||||
pets = SwaggerClient::PetApi.find_pets_by_status(:status => "available,sold")
|
pets = SwaggerClient::PetApi.find_pets_by_status(:status => "available,sold")
|
||||||
pets.map {|pet|
|
pets.each do |pet|
|
||||||
if(pet.status != 'available' && pet.status != 'sold')
|
if pet.status != 'available' && pet.status != 'sold'
|
||||||
raise "pet status wasn't right"
|
raise "pet status wasn't right"
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should update a pet" do
|
it "should update a pet" do
|
||||||
|
@ -10,4 +10,14 @@ describe "Store" do
|
|||||||
item = SwaggerClient::StoreApi.get_order_by_id(10002)
|
item = SwaggerClient::StoreApi.get_order_by_id(10002)
|
||||||
item.id.should == 10002
|
item.id.should == 10002
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user