mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2331 from rackspace/test_fix5
[Rackspace] Fix broken tests and exception handing
This commit is contained in:
commit
045f53dcee
4 changed files with 31 additions and 10 deletions
|
@ -64,9 +64,12 @@ module Fog
|
|||
class ServiceUnavailable < ServiceError; end
|
||||
class MethodNotAllowed < ServiceError; end
|
||||
class BadRequest < ServiceError
|
||||
#TODO - Need to find a better way to print out these validation errors when they are thrown
|
||||
attr_reader :validation_errors
|
||||
|
||||
def to_s
|
||||
"#{super} - #{validation_errors}"
|
||||
end
|
||||
|
||||
def self.slurp(error, service=nil)
|
||||
new_error = super(error)
|
||||
unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
|
||||
|
|
|
@ -13,10 +13,26 @@ module Fog
|
|||
class IdentifierTaken < Fog::Errors::Error; end
|
||||
class ServiceError < Fog::Rackspace::Errors::ServiceError; end
|
||||
class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end
|
||||
class BadRequest < Fog::Rackspace::Errors::BadRequest; end
|
||||
class Conflict < Fog::Rackspace::Errors::Conflict; end
|
||||
class ServiceUnavailable < Fog::Rackspace::Errors::ServiceUnavailable; end
|
||||
|
||||
|
||||
class BadRequest < Fog::Rackspace::Errors::BadRequest
|
||||
attr_reader :validation_errors
|
||||
|
||||
def self.slurp(error, service=nil)
|
||||
new_error = super(error)
|
||||
if new_error.response_data && new_error.response_data['details']
|
||||
new_error.instance_variable_set(:@validation_errors, new_error.response_data['details'])
|
||||
end
|
||||
|
||||
status_code = error.response ? error.response.status : nil
|
||||
new_error.instance_variable_set(:@status_code, status_code)
|
||||
new_error.set_transaction_id(error, service)
|
||||
new_error
|
||||
end
|
||||
end
|
||||
|
||||
requires :rackspace_api_key, :rackspace_username
|
||||
recognizes :rackspace_auth_url
|
||||
recognizes :persistent
|
||||
|
|
|
@ -39,8 +39,8 @@ Shindo.tests('Fog::Rackspace::Monitoring | list_tests', ['rackspace','rackspace_
|
|||
tests('#get list of data points').formats(LIST_HEADERS_FORMAT) do
|
||||
options = {
|
||||
:points => 1,
|
||||
:from => now,
|
||||
:to => now+SLEEP_TIME
|
||||
:from => now * 1000,
|
||||
:to => (now+SLEEP_TIME) * 1000
|
||||
}
|
||||
account.list_data_points(entity_id,check_id,metric_name,options).data[:headers]
|
||||
end
|
||||
|
|
|
@ -306,18 +306,20 @@ Shindo.tests('Fog::Storage[:rackspace] | large object requests', ['rackspace'])
|
|||
|
||||
tests('#delete_static_large_object with missing container') do
|
||||
response = Fog::Storage[:rackspace].delete_static_large_object('fognoncontainer', 'fog_large_object')
|
||||
|
||||
returns(200) { response.status }
|
||||
returns(0) { response.body["Number Not Found"] }
|
||||
returns("400 Bad Request") { response.body["Response Status"]}
|
||||
returns("Invalid bulk delete.") { response.body["Response Body"]}
|
||||
returns(1) { response.body["Number Not Found"] }
|
||||
returns("200 OK") { response.body["Response Status"]}
|
||||
returns("") { response.body["Response Body"]}
|
||||
end
|
||||
|
||||
tests('#delete_static_large_object with missing manifest') do
|
||||
response = Fog::Storage[:rackspace].delete_static_large_object(@directory.identity, 'fog_non_object')
|
||||
|
||||
returns(200) { response.status }
|
||||
returns(0) { response.body["Number Not Found"] }
|
||||
returns("400 Bad Request") { response.body["Response Status"]}
|
||||
returns("Invalid bulk delete.") { response.body["Response Body"]}
|
||||
returns(1) { response.body["Number Not Found"] }
|
||||
returns("200 OK") { response.body["Response Status"]}
|
||||
returns("") { response.body["Response Body"]}
|
||||
end
|
||||
|
||||
tests('#delete_static_large_object with missing segment') do
|
||||
|
|
Loading…
Reference in a new issue