diff --git a/lib/fog/rackspace/requests/monitoring/update_entity.rb b/lib/fog/rackspace/requests/monitoring/update_entity.rb index 46303ac5f..5eaa1e97d 100644 --- a/lib/fog/rackspace/requests/monitoring/update_entity.rb +++ b/lib/fog/rackspace/requests/monitoring/update_entity.rb @@ -3,15 +3,44 @@ module Fog class Monitoring class Real - def update_entity(id, options) + def update_entity(entity_id, options) request( :body => JSON.encode(options), :expects => [204], :method => 'PUT', - :path => "entities/#{id}" + :path => "entities/#{entity_id}" ) end end + + class Mock + + def update_entity(entity_id, options) + + if entity_id == -1 + raise Fog::Rackspace::Monitoring::NotFound + end + + response = Excon::Response.new + response.status = 204 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/entities/" + entity_id.to_s, + "X-Object-ID" => entity_id.to_s, + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "47877", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => "lakbngf9bsgkn69gb39sobnsv", + "X-LB" => "dfw1-maas-prod-api1", + "Content-Length" => "0", + "Content-Type" => "text/plain" + } + response.remote_ip = "1.1.1.1" + 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 6f76a9a3e..50fd2b87b 100644 --- a/tests/rackspace/requests/monitoring/entity_tests.rb +++ b/tests/rackspace/requests/monitoring/entity_tests.rb @@ -12,8 +12,7 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspac account.get_entity(:entity_id => "fooid") end tests('#update entity').formats(DATA_FORMAT) do - pending if Fog.mocking? - options = { :testing => "Bar"} + options = { :metadata => {:testing => "Bar" }} account.update_entity(entity_id,options).data end tests('#delete entity').formats(DELETE_DATA_FORMAT) do @@ -28,8 +27,7 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspac account.get_entity(-1) end tests('#update invalid entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do - pending if Fog.mocking? - options = { :testing => "Bar" } + options = { :metadata => {:testing => "Bar" }} response = account.update_entity(-1,options) end tests('#delete entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do