mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
list_alarm and get_alarm mock support
This commit is contained in:
parent
1d13f64c15
commit
ca185960e4
4 changed files with 102 additions and 4 deletions
|
@ -10,7 +10,21 @@ module Fog
|
||||||
:path => "entities/#{entity_id}/alarms/#{alarm_id}"
|
:path => "entities/#{entity_id}/alarms/#{alarm_id}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def delete_alarm(entity_id, alarm_id)
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.status = 204
|
||||||
|
response.body = ""
|
||||||
|
response.headers = {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
response
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,44 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def get_alarm(entity_id, alarm_id)
|
||||||
|
|
||||||
|
if entity_id == -1 || alarm_id == -1
|
||||||
|
raise Fog::Rackspace::Monitoring::NotFound
|
||||||
|
end
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
"id" => alarm_id,
|
||||||
|
"label" => nil,
|
||||||
|
"check_id" => Fog::Mock.random_letters(10),
|
||||||
|
"criteria" => nil,
|
||||||
|
"disabled" => false,
|
||||||
|
"notification_plan_id" => "npTechnicalContactsEmail",
|
||||||
|
"metadata" => nil,
|
||||||
|
"created_at" => Time.now.to_i - 1,
|
||||||
|
"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" => "38687",
|
||||||
|
"X-RateLimit-Window" => "24 hours",
|
||||||
|
"X-RateLimit-Type" => "global",
|
||||||
|
"X-Response-Id" => "pomkondbno93gm3030fm303.mmowd",
|
||||||
|
"X-LB" => "ord1-maas-prod-api0",
|
||||||
|
"Vary" => "Accept-Encoding",
|
||||||
|
"Transfer-Encoding" => "chunked"
|
||||||
|
}
|
||||||
|
response.remote_ip = Fog::Rackspace::MockData.ipv4_address
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,56 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def list_alarms(entity_id)
|
||||||
|
|
||||||
|
if entity_id == -1
|
||||||
|
raise Fog::Rackspace::Monitoring::NotFound
|
||||||
|
end
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
"values" => [
|
||||||
|
{
|
||||||
|
"id" => Fog::Mock.random_letters(10),
|
||||||
|
"label" => nil,
|
||||||
|
"check_id" => Fog::Mock.random_letters(10),
|
||||||
|
"criteria" => nil,
|
||||||
|
"disabled" => false,
|
||||||
|
"notification_plan_id" => "npTechnicalContactsEmail",
|
||||||
|
"metadata" => nil,
|
||||||
|
"created_at" => Time.now.to_i - 1,
|
||||||
|
"updated_at" => Time.now.to_i
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata" =>
|
||||||
|
{
|
||||||
|
"count" =>1,
|
||||||
|
"limit" =>100,
|
||||||
|
"marker" =>nil,
|
||||||
|
"next_marker" =>nil,
|
||||||
|
"next_href" =>nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.headers = {
|
||||||
|
"Date" => Time.now.utc.to_s,
|
||||||
|
"Content-Type" => "application/json; charset=UTF-8",
|
||||||
|
"X-RateLimit-Limit" => "50000",
|
||||||
|
"X-RateLimit-Remaining" => "38687",
|
||||||
|
"X-RateLimit-Window" => "24 hours",
|
||||||
|
"X-RateLimit-Type" => "global",
|
||||||
|
"X-Response-Id" => "pomegmgm3030fm303.mmowd",
|
||||||
|
"X-LB" => "ord1-maas-prod-api0",
|
||||||
|
"Vary" => "Accept-Encoding",
|
||||||
|
"Transfer-Encoding" => "chunked"
|
||||||
|
}
|
||||||
|
response.remote_ip = Fog::Rackspace::MockData.ipv4_address
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,11 +24,9 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace
|
||||||
account.update_alarm(entity_id,alarm_id,options).data
|
account.update_alarm(entity_id,alarm_id,options).data
|
||||||
end
|
end
|
||||||
tests('#list alarms').formats(LIST_HEADERS_FORMAT) do
|
tests('#list alarms').formats(LIST_HEADERS_FORMAT) do
|
||||||
pending if Fog.mocking?
|
|
||||||
account.list_alarms(entity_id).data[:headers]
|
account.list_alarms(entity_id).data[:headers]
|
||||||
end
|
end
|
||||||
tests('#get alarm').formats(LIST_HEADERS_FORMAT) do
|
tests('#get alarm').formats(LIST_HEADERS_FORMAT) do
|
||||||
pending if Fog.mocking?
|
|
||||||
account.get_alarm(entity_id,alarm_id).data[:headers]
|
account.get_alarm(entity_id,alarm_id).data[:headers]
|
||||||
end
|
end
|
||||||
tests('#delete alarm').formats(DELETE_DATA_FORMAT) do
|
tests('#delete alarm').formats(DELETE_DATA_FORMAT) do
|
||||||
|
@ -46,11 +44,9 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm_tests', ['rackspace','rackspace
|
||||||
response = account.update_alarm(-1,-1,options)
|
response = account.update_alarm(-1,-1,options)
|
||||||
end
|
end
|
||||||
tests('#fail to list alarms').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#fail to list alarms').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
pending if Fog.mocking?
|
|
||||||
account.list_alarms(-1)
|
account.list_alarms(-1)
|
||||||
end
|
end
|
||||||
tests('#fail to get alarm').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#fail to get alarm').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
pending if Fog.mocking?
|
|
||||||
account.get_alarm(-1,-1)
|
account.get_alarm(-1,-1)
|
||||||
end
|
end
|
||||||
tests('#fail to delete alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#fail to delete alarm(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
|
|
Loading…
Reference in a new issue