mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2070 from burns/openstack_compute_flavor_tests
[openstack|compute] update flavor tests
This commit is contained in:
commit
76badcf8d5
4 changed files with 34 additions and 19 deletions
|
@ -21,7 +21,7 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"flavor_access" => [{ "tenant_id" => tenant_id, "flavor_id" => flavor_ref }]
|
||||
"flavor_access" => [{ "tenant_id" => tenant_id.to_s, "flavor_id" => flavor_ref.to_s }]
|
||||
}
|
||||
response
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"flavor_access" => [{ "tenant_id" => @tenant_id, "flavor_id" => flavor_ref }]
|
||||
"flavor_access" => [{ "tenant_id" => @tenant_id.to_s, "flavor_id" => flavor_ref.to_s }]
|
||||
}
|
||||
response
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
|||
request(
|
||||
:body => MultiJson.encode({
|
||||
"removeTenantAccess" => {
|
||||
"tenant" => tenant_id
|
||||
"tenant" => tenant_id.to_s
|
||||
}
|
||||
}),
|
||||
:expects => [200, 203],
|
||||
|
|
|
@ -16,39 +16,39 @@ Shindo.tests('Fog::Compute[:openstack] | flavor requests', ['openstack']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests('#get_flavor_details(1)').formats(@flavor_format, false) do
|
||||
tests('#get_flavor_details(1)').data_matches_schema(@flavor_format) do
|
||||
Fog::Compute[:openstack].get_flavor_details("1").body['flavor']
|
||||
end
|
||||
|
||||
tests('#list_flavors').formats({'flavors' => [OpenStack::Compute::Formats::SUMMARY]}) do
|
||||
tests('#list_flavors').data_matches_schema({'flavors' => [OpenStack::Compute::Formats::SUMMARY]}) do
|
||||
Fog::Compute[:openstack].list_flavors.body
|
||||
end
|
||||
|
||||
tests('#list_flavors_detail').formats({'flavors' => [@flavor_format]}, false) do
|
||||
tests('#list_flavors_detail').data_matches_schema({'flavors' => [@flavor_format]}) do
|
||||
Fog::Compute[:openstack].list_flavors_detail.body
|
||||
end
|
||||
|
||||
tests('#create_flavor(attributes)').formats({'flavor' => @flavor_format}) do
|
||||
tests('#create_flavor(attributes)').data_matches_schema({'flavor' => @flavor_format}) do
|
||||
attributes = {:flavor_id => '100', :name => 'shindo test flavor', :disk => 10, :ram => 10, :vcpus => 10, :swap => "0", :rxtx_factor => 2.4, :ephemeral => 0, :is_public => false}
|
||||
Fog::Compute[:openstack].create_flavor(attributes).body
|
||||
end
|
||||
|
||||
tests('add_flavor_access(flavor_ref, tenant_id)').data_matches_schema({'flavor_access' => [{'tenant_id' => String, 'flavor_id' => String}]}) do
|
||||
Fog::Compute[:openstack].add_flavor_access(100, 1).body
|
||||
end
|
||||
|
||||
tests('remove_flavor_access(flavor_ref, tenant_id)').data_matches_schema({'flavor_access' => []}) do
|
||||
Fog::Compute[:openstack].remove_flavor_access(100, 1).body
|
||||
end
|
||||
|
||||
tests('list_tenants_with_flavor_access(flavor_ref)').data_matches_schema({'flavor_access' => [{'tenant_id' => String, 'flavor_id' => String}]}) do
|
||||
Fog::Compute[:openstack].list_tenants_with_flavor_access(100).body
|
||||
end
|
||||
|
||||
tests('delete_flavor(flavor_id)').succeeds do
|
||||
Fog::Compute[:openstack].delete_flavor('100')
|
||||
end
|
||||
|
||||
tests('add_flavor_access(flavor_ref, tenant_id)').formats({'flavor_access' => [{'tenant_id' => 1, 'flavor_id' => 1}]}) do
|
||||
Fog::Compute[:openstack].add_flavor_access(1, 1).body
|
||||
end
|
||||
|
||||
tests('remove_flavor_access(flavor_ref, tenant_id)').formats({'flavor_access' => []}) do
|
||||
Fog::Compute[:openstack].remove_flavor_access(1, 1).body
|
||||
end
|
||||
|
||||
tests('list_tenants_with_flavor_access(flavor_ref)').formats({'flavor_access' => [{'tenant_id' => nil, 'flavor_id' => 1}]}) do
|
||||
Fog::Compute[:openstack].list_tenants_with_flavor_access(1).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
@ -57,6 +57,21 @@ Shindo.tests('Fog::Compute[:openstack] | flavor requests', ['openstack']) do
|
|||
Fog::Compute[:openstack].get_flavor_details("0")
|
||||
end
|
||||
|
||||
tests('add_flavor_access(1234, 1)').raises(Fog::Compute::OpenStack::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:openstack].add_flavor_access(1234, 1).body
|
||||
end
|
||||
|
||||
tests('remove_flavor_access(1234, 1)').raises(Fog::Compute::OpenStack::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:openstack].remove_flavor_access(1234, 1).body
|
||||
end
|
||||
|
||||
tests('list_tenants_with_flavor_access(1234)').raises(Fog::Compute::OpenStack::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:openstack].list_tenants_with_flavor_access(1234)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue