From 6d0acb00a28d3459e105e3d35e8d77f3edfa1513 Mon Sep 17 00:00:00 2001 From: Mike Pountney Date: Sun, 8 Jun 2014 22:18:59 +0100 Subject: [PATCH] Add Mock for get_runtime_info_section_type --- .../compute/get_runtime_info_section_type.rb | 32 +++++++++++++++++++ .../requests/compute/get_vapp.rb | 13 -------- .../requests/compute/vm_tests.rb | 6 ++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb b/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb index 35e42c607..b73826fc1 100644 --- a/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb +++ b/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb @@ -20,6 +20,38 @@ module Fog ) end end + + class Mock + def get_runtime_info_section_type(id) + + type = 'application/vnd.vmware.vcloud.virtualHardwareSection+xml' + + unless vm = data[:vms][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_vm_runtime_info_section_body(id, vm) + ) + end + + def get_vm_runtime_info_section_body(id, vm) + { + :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5", + :ns12_href => make_href("vApp/#{id}/runtimeInfoSection"), + :ns12_type => "application/vnd.vmware.vcloud.virtualHardwareSection+xml", + :"ovf:Info" => "Specifies Runtime info", + :VMWareTools => { + :version => "9282", + } + } + end + + end end end end diff --git a/lib/fog/vcloud_director/requests/compute/get_vapp.rb b/lib/fog/vcloud_director/requests/compute/get_vapp.rb index 4778adc3f..2271960da 100644 --- a/lib/fog/vcloud_director/requests/compute/get_vapp.rb +++ b/lib/fog/vcloud_director/requests/compute/get_vapp.rb @@ -144,19 +144,6 @@ module Fog } end - - def get_vm_runtime_info_section_body(id, vm) - { - :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5", - :ns12_href => make_href("vApp/#{id}/runtimeInfoSection"), - :ns12_type => "application/vnd.vmware.vcloud.virtualHardwareSection+xml", - :"ovf:Info" => "Specifies Runtime info", - :VMWareTools => { - :version => "9282", - } - } - end - def get_vm_virtual_hardware_section_body(id, vm) {:xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5", diff --git a/tests/vcloud_director/requests/compute/vm_tests.rb b/tests/vcloud_director/requests/compute/vm_tests.rb index 5fda3ad9a..0c5505312 100644 --- a/tests/vcloud_director/requests/compute/vm_tests.rb +++ b/tests/vcloud_director/requests/compute/vm_tests.rb @@ -69,9 +69,11 @@ Shindo.tests('Compute::VcloudDirector | vm requests', ['vclouddirector']) do @service.get_product_sections_vapp(vm_id).body.class end + tests("#get_vapp(#{vm_id}).body[:RuntimeInfoSection]").data_matches_schema(VcloudDirector::Compute::Schema::RUNTIME_INFO_SECTION_TYPE) do + @service.get_vapp(vm_id).body[:RuntimeInfoSection] + end + tests("#get_runtime_info_section_type(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::RUNTIME_INFO_SECTION_TYPE) do - pending if Fog.mocking? - pending # fails if WMware Tools not installed @service.get_runtime_info_section_type(vm_id).body end