diff --git a/lib/fog/rackspace/requests/monitoring/get_entity.rb b/lib/fog/rackspace/requests/monitoring/get_entity.rb index 95166ef03..c385884eb 100644 --- a/lib/fog/rackspace/requests/monitoring/get_entity.rb +++ b/lib/fog/rackspace/requests/monitoring/get_entity.rb @@ -12,6 +12,39 @@ module Fog end end + + class Mock + def get_entity(entity_id) + response = Excon::Response.new + response.status = 200 + response.body = { + "id" => entity_id, + "label"=>"mocked_fog_entitiy", + "ip_addresses"=>{ + "private0_v4"=>"10.0.0.1" + }, + "metadata"=>nil, + "managed"=>false, + "uri"=>"https://ord.servers.api.rackspacecloud.com/5555/servers/23kj2q4hk234", + "agent_id"=>nil, + "created_at"=> Time.now.to_i - 5000, + "updated_at"=> Time.now.to_i + } + response.headers = { + "Date"=> Time.now.utc.to_s, + "Content-Type"=>"application/json; charset=UTF-8", + "X-RateLimit-Limit"=>"50000", + "X-RateLimit-Remaining"=>"49627", + "X-RateLimit-Window"=>"24 hours", + "X-RateLimit-Type"=>"global", + "X-Response-Id"=>"j23jlk234jl2j34j", + "X-LB"=>"dfw1-maas-prod-api0", + "Vary"=>"Accept-Encoding", + "Transfer-Encoding"=>"chunked" + } + response + end + end end end end diff --git a/tests/rackspace/requests/monitoring/entity_tests.rb b/tests/rackspace/requests/monitoring/entity_tests.rb index 9476aa72f..76c2b0138 100644 --- a/tests/rackspace/requests/monitoring/entity_tests.rb +++ b/tests/rackspace/requests/monitoring/entity_tests.rb @@ -1,9 +1,9 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspace_monitoring']) do - pending if Fog.mocking? account = Fog::Rackspace::Monitoring.new entity_id = nil tests('success') do tests('#create new entity').formats(DATA_FORMAT) do + pending if Fog.mocking? response = account.create_entity(:label => "Foo").data entity_id = response[:headers]["X-Object-ID"] response @@ -12,25 +12,33 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspac account.get_entity(entity_id).data[:headers] end tests('#update entity').formats(DATA_FORMAT) do + pending if Fog.mocking? + options = { :testing => "Bar"} account.update_entity(entity_id,options).data end tests('#delete entity').formats(DELETE_DATA_FORMAT) do + pending if Fog.mocking? account.delete_entity(entity_id).data end end tests('failure') do tests('#create new entity(-1)').raises(Fog::Rackspace::Monitoring::BadRequest) do + pending if Fog.mocking? account.create_entity(:label => "") end tests('#get entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do + pending if Fog.mocking? + account.get_entity(-1) end tests('#update invalid entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do + pending if Fog.mocking? options = { :testing => "Bar" } response = account.update_entity(-1,options) end tests('#delete entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do + pending if Fog.mocking? account.delete_entity(-1) end end