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

add create_entity mock support

This commit is contained in:
Ryan Richard 2013-08-29 10:50:20 -05:00
parent b9ac2838f2
commit acc2b78a37
2 changed files with 32 additions and 1 deletions

View file

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

View file

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