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

[openstack|network] Added missing router related tests

This commit is contained in:
Sergio Rubio 2013-02-26 17:16:55 +01:00
parent 596e54fec2
commit 55cffa7ad0
3 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,38 @@
Shindo.tests("Fog::Network[:openstack] | router", ['openstack']) do
tests('success') do
tests('#create').succeeds do
@instance = Fog::Network[:openstack].routers.create(
:name => 'router_name',
:admin_state_up => true,
)
!@instance.id.nil?
end
tests('#update') do
test 'router name' do
@instance.name = 'new_name'
@instance.update.name == 'new_name'
end
# Needs code from issue #1598
#test 'external_gateway_info' do
# net = Fog::Network[:openstack].networks.create(
# :name => 'net_name',
# :shared => false,
# :admin_state_up => true,
# :tenant_id => 'tenant_id',
# :router_external => true,
# )
# @instance.external_gateway_info = net
# @instance.update
#end
end
tests('#destroy').succeeds do
@instance.destroy == true
end
end
end

View file

@ -0,0 +1,21 @@
Shindo.tests("Fog::Network[:openstack] | routers", ['openstack']) do
@router = Fog::Network[:openstack].routers.create(
:name => 'router_name',
:admin_state_up => true,
)
@routers = Fog::Network[:openstack].routers
tests('success') do
tests('#all').succeeds do
@routers.all
end
tests('#get').succeeds do
@routers.get @router.id
end
end
@router.destroy
end

View file

@ -0,0 +1,75 @@
Shindo.tests('Fog::Network[:openstack] | router requests', ['openstack']) do
@router_format = {
'id' => String,
'name' => String,
'status' => String,
'admin_state_up' => Fog::Boolean,
'tenant_id' => String,
'external_gateway_info' => Fog::Nullable::Hash,
}
tests('success') do
tests('#create_router').formats({'router' => @router_format}) do
attributes = {
:admin_state_up => true,
:tenant_id => 'tenant_id'
}
Fog::Network[:openstack].create_router('router_name', attributes).body
end
tests('#list_routers').formats({'routers' => [@router_format]}) do
Fog::Network[:openstack].list_routers.body
end
tests('#get_router').formats({'router' => @router_format}) do
router_id = Fog::Network[:openstack].routers.all.first.id
Fog::Network[:openstack].get_router(router_id).body
end
tests('#update_router').formats({'router' => @router_format}) do
router_id = Fog::Network[:openstack].routers.all.first.id
attributes = {}
{
:name => 'net_name',
:external_gateway_info => { :network_id => 'net_id' },
:status => 'ACTIVE',
:admin_state_up => 'true'
}
Fog::Network[:openstack].update_router(router_id, attributes).body
end
tests('#update_router_with_network').formats({'router' => @router_format}) do
router_id = Fog::Network[:openstack].routers.all.first.id
net = Fog::Network[:openstack].networks.first
attributes = {}
{
:name => 'net_name',
:external_gateway_info => net,
:status => 'ACTIVE',
:admin_state_up => 'true'
}
Fog::Network[:openstack].update_router(router_id, attributes).body
end
tests('#delete_router').succeeds do
router_id = Fog::Network[:openstack].routers.all.last.id
Fog::Network[:openstack].delete_router(router_id)
end
end
tests('failure') do
tests('#get_router').raises(Fog::Network::OpenStack::NotFound) do
Fog::Network[:openstack].get_router(0)
end
tests('#update_router').raises(Fog::Network::OpenStack::NotFound) do
Fog::Network[:openstack].update_router(0, {})
end
tests('#delete_router').raises(Fog::Network::OpenStack::NotFound) do
Fog::Network[:openstack].delete_router(0)
end
end
end