mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add LeaseSettingSection Mocks for vApps
This commit is contained in:
parent
a1c1649d51
commit
cf45a85039
4 changed files with 63 additions and 15 deletions
|
@ -20,6 +20,40 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def get_lease_settings_section_vapp(id)
|
||||||
|
|
||||||
|
type = 'application/vnd.vmware.vcloud.leaseSettingsSection+xml'
|
||||||
|
|
||||||
|
unless vapp = data[:vapps][id]
|
||||||
|
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||||
|
'This operation is denied.'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
Excon::Response.new(
|
||||||
|
:status => 200,
|
||||||
|
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||||
|
:body => get_vapp_lease_settings_section_body(id)
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_vapp_lease_settings_section_body(id)
|
||||||
|
{
|
||||||
|
:type => "application/vnd.vmware.vcloud.leaseSettingsSection+xml",
|
||||||
|
:href => make_href("vApp/#{id}/leaseSettingsSection/"),
|
||||||
|
:ovf_required=>"false",
|
||||||
|
:"ovf:Info"=>"Lease settings section",
|
||||||
|
:DeploymentLeaseInSeconds=>"0",
|
||||||
|
:StorageLeaseInSeconds=>"0",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -92,7 +92,7 @@ module Fog
|
||||||
:name => vapp[:name],
|
:name => vapp[:name],
|
||||||
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
||||||
:href => make_href("vApp/#{id}"),
|
:href => make_href("vApp/#{id}"),
|
||||||
:LeaseSettingsSection => get_vapp_lease_settings_section_body(id, vapp),
|
:LeaseSettingsSection => get_vapp_lease_settings_section_body(id),
|
||||||
:"ovf:StartupSection" => get_vapp_ovf_startup_section_body(id, vapp),
|
:"ovf:StartupSection" => get_vapp_ovf_startup_section_body(id, vapp),
|
||||||
:"ovf:NetworkSection" => get_vapp_ovf_network_section_body(id, vapp),
|
:"ovf:NetworkSection" => get_vapp_ovf_network_section_body(id, vapp),
|
||||||
:NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
|
:NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
|
||||||
|
@ -107,17 +107,6 @@ module Fog
|
||||||
body
|
body
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_vapp_lease_settings_section_body(id, vapp)
|
|
||||||
{
|
|
||||||
:type => "application/vnd.vmware.vcloud.leaseSettingsSection+xml",
|
|
||||||
:href => make_href("vApp/#{id}/leaseSettingsSection/"),
|
|
||||||
:ovf_required=>"false",
|
|
||||||
:"ovf:Info"=>"Lease settings section",
|
|
||||||
:DeploymentLeaseInSeconds=>"0",
|
|
||||||
:StorageLeaseInSeconds=>"0",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_vapp_ovf_startup_section_body(id, vapp)
|
def get_vapp_ovf_startup_section_body(id, vapp)
|
||||||
{
|
{
|
||||||
:xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
|
:xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
|
||||||
|
|
|
@ -15,15 +15,28 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
||||||
@vapp_id = v[:href].split('/').last
|
@vapp_id = v[:href].split('/').last
|
||||||
|
|
||||||
#tests("#get_vapp(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::VAPP_TYPE) do
|
#tests("#get_vapp(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::VAPP_TYPE) do
|
||||||
tests("#get_vapp(#{@vapp_id})").returns(Hash) do
|
tests("#get_vapp(#{@vapp_id}).body").returns(Hash) do
|
||||||
pending if Fog.mocking?
|
|
||||||
@service.get_vapp(@vapp_id).body.class
|
@service.get_vapp(@vapp_id).body.class
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#get_vapp(#{@vapp_id}).body[:name]").returns(String) do
|
||||||
|
@service.get_vapp(@vapp_id).body[:name].class
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#get_vapp(#{@vapp_id}).body[:href]").returns(v[:href]) do
|
||||||
|
@service.get_vapp(@vapp_id).body[:href]
|
||||||
|
end
|
||||||
|
|
||||||
tests("#get_lease_settings_section_vapp(#{@vapp_id})").returns(Hash) do
|
tests("#get_lease_settings_section_vapp(#{@vapp_id})").returns(Hash) do
|
||||||
pending if Fog.mocking?
|
|
||||||
@service.get_lease_settings_section_vapp(@vapp_id).body.class
|
@service.get_lease_settings_section_vapp(@vapp_id).body.class
|
||||||
end
|
end
|
||||||
|
tests("#get_lease_settings_section_vapp(#{@vapp_id}).body[:DeploymentLeaseInSeconds] is >= 0").returns(true) do
|
||||||
|
Integer(@service.get_lease_settings_section_vapp(@vapp_id).body[:DeploymentLeaseInSeconds]) >= 0
|
||||||
|
end
|
||||||
|
tests("#get_vapp(#{@vapp_id}).body[:LeaseSettingsSection[:DeploymentLeaseInSeconds] is >= 0").returns(true) do
|
||||||
|
Integer(@service.get_vapp(@vapp_id).body[:LeaseSettingsSection][:DeploymentLeaseInSeconds]) >= 0
|
||||||
|
end
|
||||||
|
|
||||||
tests("#get_network_config_section_vapp(#{@vapp_id})").returns(Hash) do
|
tests("#get_network_config_section_vapp(#{@vapp_id})").returns(Hash) do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
@service.get_network_config_section_vapp(@vapp_id).body.class
|
@service.get_network_config_section_vapp(@vapp_id).body.class
|
||||||
|
|
|
@ -19,6 +19,18 @@ Shindo.tests('Compute::VcloudDirector | vm requests', ['vclouddirector']) do
|
||||||
vapp[:Children][:Vm].each do |vm|
|
vapp[:Children][:Vm].each do |vm|
|
||||||
vm_id = vm[:href].split('/').last
|
vm_id = vm[:href].split('/').last
|
||||||
|
|
||||||
|
tests("#get_vapp(#{vm_id}).body").returns(Hash) do
|
||||||
|
@service.get_vapp(vm_id).body.class
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#get_vapp(#{vm_id}).body[:name]").returns(String) do
|
||||||
|
@service.get_vapp(vm_id).body[:name].class
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#get_vapp(#{vm_id}).body[:href]").returns(vm[:href]) do
|
||||||
|
@service.get_vapp(vm_id).body[:href]
|
||||||
|
end
|
||||||
|
|
||||||
tests("#get_guest_customization_system_section_vapp(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::GUEST_CUSTOMIZATION_SECTION_TYPE) do
|
tests("#get_guest_customization_system_section_vapp(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::GUEST_CUSTOMIZATION_SECTION_TYPE) do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
@service.get_guest_customization_system_section_vapp(vm_id).body
|
@service.get_guest_customization_system_section_vapp(vm_id).body
|
||||||
|
|
Loading…
Add table
Reference in a new issue