mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2102 from rackspace/entity_mock1
[rackspace|monitoring] adding mocks for get_entity
This commit is contained in:
commit
7bfaef6dcc
2 changed files with 42 additions and 1 deletions
|
@ -12,6 +12,39 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_entity(entity_id)
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
"id" => entity_id,
|
||||||
|
"label"=>"mocked_fog_entitiy",
|
||||||
|
"ip_addresses"=>{
|
||||||
|
"private0_v4"=>"10.0.0.1"
|
||||||
|
},
|
||||||
|
"metadata"=>nil,
|
||||||
|
"managed"=>false,
|
||||||
|
"uri"=>"https://ord.servers.api.rackspacecloud.com/5555/servers/23kj2q4hk234",
|
||||||
|
"agent_id"=>nil,
|
||||||
|
"created_at"=> Time.now.to_i - 5000,
|
||||||
|
"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"=>"49627",
|
||||||
|
"X-RateLimit-Window"=>"24 hours",
|
||||||
|
"X-RateLimit-Type"=>"global",
|
||||||
|
"X-Response-Id"=>"j23jlk234jl2j34j",
|
||||||
|
"X-LB"=>"dfw1-maas-prod-api0",
|
||||||
|
"Vary"=>"Accept-Encoding",
|
||||||
|
"Transfer-Encoding"=>"chunked"
|
||||||
|
}
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspace_monitoring']) do
|
Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspace_monitoring']) do
|
||||||
pending if Fog.mocking?
|
|
||||||
account = Fog::Rackspace::Monitoring.new
|
account = Fog::Rackspace::Monitoring.new
|
||||||
entity_id = nil
|
entity_id = nil
|
||||||
tests('success') do
|
tests('success') do
|
||||||
tests('#create new entity').formats(DATA_FORMAT) do
|
tests('#create new entity').formats(DATA_FORMAT) do
|
||||||
|
pending if Fog.mocking?
|
||||||
response = account.create_entity(:label => "Foo").data
|
response = account.create_entity(:label => "Foo").data
|
||||||
entity_id = response[:headers]["X-Object-ID"]
|
entity_id = response[:headers]["X-Object-ID"]
|
||||||
response
|
response
|
||||||
|
@ -12,25 +12,33 @@ Shindo.tests('Fog::Rackspace::Monitoring | entity_tests', ['rackspace','rackspac
|
||||||
account.get_entity(entity_id).data[:headers]
|
account.get_entity(entity_id).data[:headers]
|
||||||
end
|
end
|
||||||
tests('#update entity').formats(DATA_FORMAT) do
|
tests('#update entity').formats(DATA_FORMAT) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
options = { :testing => "Bar"}
|
options = { :testing => "Bar"}
|
||||||
account.update_entity(entity_id,options).data
|
account.update_entity(entity_id,options).data
|
||||||
end
|
end
|
||||||
tests('#delete entity').formats(DELETE_DATA_FORMAT) do
|
tests('#delete entity').formats(DELETE_DATA_FORMAT) do
|
||||||
|
pending if Fog.mocking?
|
||||||
account.delete_entity(entity_id).data
|
account.delete_entity(entity_id).data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tests('failure') do
|
tests('failure') do
|
||||||
tests('#create new entity(-1)').raises(Fog::Rackspace::Monitoring::BadRequest) do
|
tests('#create new entity(-1)').raises(Fog::Rackspace::Monitoring::BadRequest) do
|
||||||
|
pending if Fog.mocking?
|
||||||
account.create_entity(:label => "")
|
account.create_entity(:label => "")
|
||||||
end
|
end
|
||||||
tests('#get entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#get entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
account.get_entity(-1)
|
account.get_entity(-1)
|
||||||
end
|
end
|
||||||
tests('#update invalid entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#update invalid entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
|
pending if Fog.mocking?
|
||||||
options = { :testing => "Bar" }
|
options = { :testing => "Bar" }
|
||||||
response = account.update_entity(-1,options)
|
response = account.update_entity(-1,options)
|
||||||
end
|
end
|
||||||
tests('#delete entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
tests('#delete entity(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do
|
||||||
|
pending if Fog.mocking?
|
||||||
account.delete_entity(-1)
|
account.delete_entity(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue