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

Create the mock Queues service.

Mostly by refactoring methods out into a Common module, much like the
Storage service.
This commit is contained in:
Ash Wilson 2014-01-20 09:47:22 -05:00
parent 272bc6b2a2
commit 798967306f

View file

@ -42,23 +42,8 @@ module Fog
request :update_claim request :update_claim
request :delete_claim request :delete_claim
class Mock < Fog::Rackspace::Service module Common
def request(params) def apply_options(options)
Fog::Mock.not_implemented
end
end
class Real < Fog::Rackspace::Service
def service_name
:cloudQueues
end
def region
@rackspace_region
end
def initialize(options = {})
@rackspace_api_key = options[:rackspace_api_key] @rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username] @rackspace_username = options[:rackspace_username]
@rackspace_queues_client_id = options[:rackspace_queues_client_id] || Fog::UUID.uuid @rackspace_queues_client_id = options[:rackspace_queues_client_id] || Fog::UUID.uuid
@ -70,25 +55,14 @@ module Fog
unless v2_authentication? unless v2_authentication?
raise Fog::Errors::NotImplemented.new("V2 authentication required for Queues") raise Fog::Errors::NotImplemented.new("V2 authentication required for Queues")
end end
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end end
def request(params, parse_json = true, &block) def service_name
super(params, parse_json, &block) :cloudQueues
rescue Excon::Errors::NotFound => error end
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error def region
raise BadRequest.slurp(error, self) @rackspace_region
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::MethodNotAllowed => error
raise MethodNotAllowed.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
end end
def endpoint_uri(service_endpoint_url=nil) def endpoint_uri(service_endpoint_url=nil)
@ -112,6 +86,47 @@ module Fog
@rackspace_queues_client_id = client_id @rackspace_queues_client_id = client_id
end end
end end
class Mock < Fog::Rackspace::Service
include Common
def initialize(options = {})
apply_options(options)
authenticate
endpoint_uri
end
def request(params)
Fog::Mock.not_implemented
end
end
class Real < Fog::Rackspace::Service
include Common
def initialize(options = {})
apply_options(options)
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::MethodNotAllowed => error
raise MethodNotAllowed.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
end
end
end end
end end
end end