1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

add update_entities mock support, minor change to variables in Real

This commit is contained in:
Ryan Richard 2013-08-29 14:32:55 -05:00
parent 2c499cdf0f
commit f8e855a50d
2 changed files with 33 additions and 6 deletions

View file

@ -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

View file

@ -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