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

added associate_floatingip and disassosiate_floatingip mock test

This commit is contained in:
kanetann 2012-12-17 16:35:28 +09:00
parent 8329f16f8d
commit a4abfa3118
4 changed files with 19121 additions and 7 deletions

View file

@ -52,15 +52,14 @@ module Fog
requires :floating_network_id requires :floating_network_id
merge_attributes(connection.assosiate_floatingip(self.floating_network_id, merge_attributes(connection.assosiate_floatingip(self.floating_network_id,
self.port_id, self.port_id,
self.fixed_ip_address,
self.attributes).body['floatingip']) self.attributes).body['floatingip'])
true self
end end
def disassosiate def disassosiate
requires :floating_network_id requires :floating_network_id
connection.disassosiate_floatingip(self.floating_network_id) connection.disassosiate_floatingip(self.floating_network_id)
true self
end end
end end
end end

View file

@ -3,14 +3,15 @@ module Fog
class OpenStack class OpenStack
class Real class Real
def associate_floatingip(floating_network_id, options = {}) def associate_floatingip(floating_network_id, port_id, options = {})
data = { data = {
'floatingip' => { 'floatingip' => {
'network_id' => floating_network_id, 'network_id' => floating_network_id,
'port_id' => port_id,
} }
} }
vanilla_options = [:port_id, :fixed_ip_address ] vanilla_options = [:fixed_ip_address]
vanilla_options.reject{ |o| options[o].nil? }.each do |key| vanilla_options.reject{ |o| options[o].nil? }.each do |key|
data['floatingip'][key] = options[key] data['floatingip'][key] = options[key]
end end
@ -25,7 +26,7 @@ module Fog
end end
class Mock class Mock
def associatee_floatingip(floating_network_id, options = {}) def associate_floatingip(floating_network_id, port_id, options = {})
response = Excon::Response.new response = Excon::Response.new
response.status = 201 response.status = 201
data = { data = {

19103
tags Normal file

File diff suppressed because it is too large Load diff

View file

@ -40,9 +40,20 @@ Shindo.tests('Fog::Network[:openstack] | floatingip requests', ['openstack']) do
Fog::Network[:openstack].update_floatingip(floating_network_id, attributes).body Fog::Network[:openstack].update_floatingip(floating_network_id, attributes).body
end end
tests('#associate_floatingip').succeeds do
floating_network_id = Fog::Network[:openstack].floatingips.all.first.id
port_id = 'p00000000-0000-0000-0000-000000000000'
Fog::Network[:openstack].associate_floatingip(floating_network_id, port_id).body
end
tests('#disassociate_floatingip').succeeds do
floating_network_id = Fog::Network[:openstack].floatingips.all.first.id
Fog::Network[:openstack].disassociate_floatingip(floating_network_id).body
end
tests('#delete_floatingip').succeeds do tests('#delete_floatingip').succeeds do
floating_network_id = Fog::Network[:openstack].floatingips.all.first.id floating_network_id = Fog::Network[:openstack].floatingips.all.first.id
Fog::Network[:openstack].delete_floatingip(floating_network_id) Fog::Network[:openstack].delete_floatingip(floating_network_id).body
end end
end end