diff --git a/lib/fog/rackspace/requests/monitoring/create_entity.rb b/lib/fog/rackspace/requests/monitoring/create_entity.rb index c639e6549..f980bfd3d 100644 --- a/lib/fog/rackspace/requests/monitoring/create_entity.rb +++ b/lib/fog/rackspace/requests/monitoring/create_entity.rb @@ -13,6 +13,30 @@ module Fog ) end end + + class Mock + + def create_entity(options = {}) + response = Excon::Response.new + response.status = 201 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/entities/foobarbaz", + "X-Object-ID" => "foobarbaz", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "47877", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => "lakbngf9bgewkgb39sobnsv", + "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 9476aa72f..8f352937c 100644 --- a/tests/rackspace/requests/monitoring/entity_tests.rb +++ b/tests/rackspace/requests/monitoring/entity_tests.rb @@ -1,5 +1,5 @@ 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 @@ -9,28 +9,35 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspac response end tests('#get entity').formats(LIST_HEADERS_FORMAT) do + pending if Fog.mocking? 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