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

nicer and more explicit messaging around mocks that are not yet implemented

This commit is contained in:
geemus (Wesley Beary) 2010-02-01 22:53:18 -08:00
parent f32578cb4c
commit 87da79eae2
24 changed files with 115 additions and 66 deletions

View file

@ -18,6 +18,8 @@ $LOAD_PATH.unshift __DIR__ unless
module Fog
class MockNotImplemented < StandardError; end
def self.mock!
@mocking = true
self.reload

View file

@ -41,24 +41,28 @@ else
# TODO: handle the GroupName/Source/Source case
def authorize_security_group_ingress(options = {})
response = Excon::Response.new
group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
raise MockNotImplemented.new("Contributions welcome!")
else
response = Excon::Response.new
group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
group['ipPermissions'] ||= []
group['ipPermissions'] << {
'groups' => [],
'fromPort' => options['FromPort'],
'ipRanges' => [{ 'cidrIp' => options['CidrIp'] }],
'ipProtocol' => options['IpProtocol'],
'toPort' => options['ToPort']
}
group['ipPermissions'] ||= []
group['ipPermissions'] << {
'groups' => [],
'fromPort' => options['FromPort'],
'ipRanges' => [{ 'cidrIp' => options['CidrIp'] }],
'ipProtocol' => options['IpProtocol'],
'toPort' => options['ToPort']
}
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
response
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
response
end
end
end

View file

@ -41,24 +41,28 @@ else
# TODO: handle the GroupName/Source/Source case
def revoke_security_group_ingress(options = {})
response = Excon::Response.new
group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
raise MockNotImplemented.new("Contributions welcome!")
else
response = Excon::Response.new
group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
ingress = group['ipPermissions'].select {|permission|
permission['fromPort'] == options['FromPort'] &&
permission['ipProtocol'] == options['IpProtocol'] &&
permission['toPort'] == options['ToPort'] &&
permission['ipRanges'].first['cidrIp'] == options['CidrIp']
}.first
ingress = group['ipPermissions'].select {|permission|
permission['fromPort'] == options['FromPort'] &&
permission['ipProtocol'] == options['IpProtocol'] &&
permission['toPort'] == options['ToPort'] &&
permission['ipRanges'].first['cidrIp'] == options['CidrIp']
}.first
group['ipPermissions'].delete(ingress)
group['ipPermissions'].delete(ingress)
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
response
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
response
end
end
end

View file

@ -114,6 +114,10 @@ else
response
end
def get_object_url(bucket_name, object_name, expires)
raise MockNotImplemented.new("Contributions welcome!")
end
end
end
end

View file

@ -1,29 +1,47 @@
module Fog
module AWS
class SimpleDB
unless Fog.mocking?
module Fog
module AWS
class SimpleDB
# Select item data from SimpleDB
#
# ==== Parameters
# * select_expression<~String> - Expression to query domain with.
# * next_token<~String> - Offset token to start list, defaults to nil.
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'BoxUsage'<~Float>
# * 'RequestId'<~String>
# * 'Items'<~Hash> - list of attribute name/values for the items formatted as
# { 'item_name' => { 'attribute_name' => ['attribute_value'] }}
# * 'NextToken'<~String> - offset to start with if there are are more domains to list
def select(select_expression, next_token = nil)
request({
'Action' => 'Select',
'NextToken' => next_token,
'SelectExpression' => select_expression
}, Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string))
end
# Select item data from SimpleDB
#
# ==== Parameters
# * select_expression<~String> - Expression to query domain with.
# * next_token<~String> - Offset token to start list, defaults to nil.
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'BoxUsage'<~Float>
# * 'RequestId'<~String>
# * 'Items'<~Hash> - list of attribute name/values for the items formatted as
# { 'item_name' => { 'attribute_name' => ['attribute_value'] }}
# * 'NextToken'<~String> - offset to start with if there are are more domains to list
def select(select_expression, next_token = nil)
request({
'Action' => 'Select',
'NextToken' => next_token,
'SelectExpression' => select_expression
}, Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string))
end
end
end
else
module Fog
module AWS
class SimpleDB
def select(select_expression, next_token = nil)
raise MockNotImplemented.new("Contributions welcome!")
end
end
end
end
end

View file

@ -28,7 +28,8 @@ else
module Rackspace
class Servers
def delete_container
def delete_container(name)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -29,7 +29,8 @@ else
module Rackspace
class Servers
def delete_object
def delete_object(container, object)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -51,7 +51,8 @@ else
module Rackspace
class Servers
def get_flavors
def get_container(container, options = {})
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -44,7 +44,8 @@ else
module Rackspace
class Servers
def get_flavors
def get_containers(options = {})
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -34,7 +34,8 @@ else
module Rackspace
class Servers
def get_flavors
def head_container(container)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -31,7 +31,8 @@ else
module Rackspace
class Servers
def get_flavors
def head_containers
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -28,7 +28,8 @@ else
module Rackspace
class Servers
def put_container
def put_container(name)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -31,7 +31,8 @@ else
module Rackspace
class Servers
def put_container
def put_object(container, object, data)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -32,6 +32,7 @@ else
class Servers
def get_flavor_details(flavor_id)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -30,6 +30,7 @@ else
class Servers
def list_flavors
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -32,6 +32,7 @@ else
class Servers
def list_flavors_detail
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -39,7 +39,6 @@ else
response.status = [200, 203][rand(1)]
response.body = { 'images' => images }
response
end
end

View file

@ -30,6 +30,7 @@ else
class Servers
def reboot_server(server_id, type)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -41,7 +41,8 @@ else
module Fog
class Slicehost
def get_slices
def create_slice(flavor_id, image_id, name)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -39,7 +39,8 @@ else
module Fog
class Slicehost
def get_slices
def delete_slice(slice_id)
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -30,6 +30,7 @@ else
class Slicehost
def get_backups
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -30,6 +30,7 @@ else
class Slicehost
def get_flavors
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -28,6 +28,7 @@ else
class Slicehost
def get_images
raise MockNotImplemented.new("Contributions welcome!")
end
end

View file

@ -36,6 +36,7 @@ else
class Slicehost
def get_slices
raise MockNotImplemented.new("Contributions welcome!")
end
end