mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add update_alarm mock support, update Real parameters to convention
This commit is contained in:
parent
ca185960e4
commit
bc7d1a5d5b
2 changed files with 33 additions and 4 deletions
|
@ -3,15 +3,46 @@ module Fog
|
|||
class Monitoring
|
||||
class Real
|
||||
|
||||
def update_alarm(entity_id, id, options)
|
||||
def update_alarm(entity_id, alarm_id, options)
|
||||
request(
|
||||
:body => JSON.encode(options),
|
||||
:expects => [204],
|
||||
:method => 'PUT',
|
||||
:path => "entities/#{entity_id}/alarms/#{id}"
|
||||
:path => "entities/#{entity_id}/alarms/#{alarm_id}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def update_alarm(entity_id, alarm_id, options)
|
||||
|
||||
account_id = Fog::Mock.random_numbers(6).to_s
|
||||
|
||||
if entity_id == -1 || alarm_id == -1 || options[:testing]
|
||||
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/" + account_id + "/entities/" + entity_id.to_s + "/alarms/" + alarm_id,
|
||||
"X-Object-ID" => alarm_id,
|
||||
"X-RateLimit-Limit" => "50000",
|
||||
"X-RateLimit-Remaining" => "47877",
|
||||
"X-RateLimit-Window" => "24 hours",
|
||||
"X-RateLimit-Type" => "global",
|
||||
"X-Response-Id" => "laolsgggopsnfksdovnsv",
|
||||
"X-LB" => "dfw1-maas-prod-api1",
|
||||
"Content-Length" => "0",
|
||||
"Content-Type" => "text/plain"
|
||||
}
|
||||
response.remote_ip = Fog::Rackspace::MockData.ipv4_address
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,6 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace
|
|||
response
|
||||
end
|
||||
tests('#update alarm').formats(DATA_FORMAT) do
|
||||
pending if Fog.mocking?
|
||||
options = { :label => "Bar"}
|
||||
account.update_alarm(entity_id,alarm_id,options).data
|
||||
end
|
||||
|
@ -39,7 +38,6 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace
|
|||
account.create_alarm(entity_id, {:type => ""})
|
||||
end
|
||||
tests('#fail to update invalid alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
options = { :testing => "Bar" }
|
||||
response = account.update_alarm(-1,-1,options)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue