mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[hp|network] Add tests for request methods of subnets.
This commit is contained in:
parent
c328f336f9
commit
06ba10e822
2 changed files with 72 additions and 1 deletions
|
@ -2,7 +2,7 @@ Shindo.tests("HP::Network | network requests", ['hp', 'network']) do
|
||||||
|
|
||||||
@network_format = {
|
@network_format = {
|
||||||
'id' => String,
|
'id' => String,
|
||||||
'name' => String,
|
'name' => Fog::Nullable::String,
|
||||||
'tenant_id' => String,
|
'tenant_id' => String,
|
||||||
'status' => String,
|
'status' => String,
|
||||||
'subnets' => Array,
|
'subnets' => Array,
|
||||||
|
|
71
tests/hp/requests/network/subnet_tests.rb
Normal file
71
tests/hp/requests/network/subnet_tests.rb
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
Shindo.tests("HP::Network | subnet requests", ['hp', 'subnet']) do
|
||||||
|
|
||||||
|
@subnet_format = {
|
||||||
|
'id' => String,
|
||||||
|
'name' => Fog::Nullable::String,
|
||||||
|
'network_id' => String,
|
||||||
|
'cidr' => String,
|
||||||
|
'ip_version' => Integer,
|
||||||
|
'gateway_ip' => Fog::Nullable::String,
|
||||||
|
'allocation_pools' => Fog::Nullable::Array,
|
||||||
|
'dns_nameservers' => Fog::Nullable::Array,
|
||||||
|
'host_routes' => Fog::Nullable::Array,
|
||||||
|
'enable_dhcp' => Fog::Boolean,
|
||||||
|
'tenant_id' => String,
|
||||||
|
}
|
||||||
|
|
||||||
|
n_data = HP[:network].create_network({:name => 'fog_network'}).body['network']
|
||||||
|
@network_id = n_data['id']
|
||||||
|
|
||||||
|
tests('success') do
|
||||||
|
|
||||||
|
@subnet_id = nil
|
||||||
|
|
||||||
|
tests('#create_subnet').formats(@subnet_format) do
|
||||||
|
attributes = {:name => 'mysubnet', :gateway_ip => '10.0.3.1',
|
||||||
|
:allocation_pools => [], :dns_nameservers => [],
|
||||||
|
:host_routes => [], :enable_dhcp => true}
|
||||||
|
data = HP[:network].create_subnet(@network_id, '10.0.3.0/24', 4, attributes).body['subnet']
|
||||||
|
@subnet_id = data['id']
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#list_subnets').formats({'subnets' => [@subnet_format]}) do
|
||||||
|
HP[:network].list_subnets.body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#get_subnet(#{@subnet_id})").formats({'subnet' => @subnet_format}) do
|
||||||
|
HP[:network].get_subnet(@subnet_id).body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#update_subnet(#{@subnet_id})").formats({'subnet' => @subnet_format}) do
|
||||||
|
attributes = {:name => 'mysubnet_upd',:gateway_ip => '10.0.3.1',
|
||||||
|
:dns_nameservers => [], :host_routes => [],
|
||||||
|
:enable_dhcp => true}
|
||||||
|
HP[:network].update_subnet(@subnet_id, attributes).body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#delete_subnet(#{@subnet_id})").succeeds do
|
||||||
|
HP[:network].delete_subnet(@subnet_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('failure') do
|
||||||
|
tests('#get_subnet(0)').raises(Fog::HP::Network::NotFound) do
|
||||||
|
HP[:network].get_subnet(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#update_subnet(0)').raises(Fog::HP::Network::NotFound) do
|
||||||
|
HP[:network].update_subnet(0, {})
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#delete_subnet(0)').raises(Fog::HP::Network::NotFound) do
|
||||||
|
HP[:network].delete_subnet(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
HP[:network].delete_network(@network_id)
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue