2012-05-28 16:22:26 -04:00
|
|
|
Shindo.tests('Fog::Compute[:network] | network model', ['xenserver']) do
|
2012-04-02 07:25:03 -04:00
|
|
|
|
|
|
|
networks = Fog::Compute[:xenserver].networks
|
|
|
|
network = networks.first
|
|
|
|
|
|
|
|
tests('The network model should') do
|
|
|
|
tests('have the action') do
|
2013-03-26 12:33:39 -04:00
|
|
|
%w{ reload refresh destroy save vifs pifs }.each do |action|
|
|
|
|
test(action) { network.respond_to? action }
|
|
|
|
#test("#{action} returns successfully") { server.send(action.to_sym) ? true : false }
|
|
|
|
end
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
tests('have attributes') do
|
|
|
|
model_attribute_hash = network.attributes
|
2014-05-26 09:44:18 -04:00
|
|
|
attributes = [
|
2012-04-02 07:25:03 -04:00
|
|
|
:reference,
|
|
|
|
:uuid,
|
|
|
|
:__vifs,
|
|
|
|
:tags,
|
|
|
|
:mtu,
|
|
|
|
:bridge,
|
|
|
|
:name,
|
|
|
|
:other_config,
|
|
|
|
:__pifs,
|
|
|
|
:allowed_operations,
|
|
|
|
:current_operations,
|
|
|
|
:blobs
|
|
|
|
]
|
|
|
|
tests("The network model should respond to") do
|
|
|
|
attributes.each do |attribute|
|
|
|
|
test("#{attribute}") { network.respond_to? attribute }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tests("The attributes hash should have key") do
|
|
|
|
attributes.each do |attribute|
|
2014-05-21 10:28:51 -04:00
|
|
|
test("#{attribute}") { model_attribute_hash.key? attribute }
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test('be a kind of Fog::Compute::XenServer::Network') { network.kind_of? Fog::Compute::XenServer::Network }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("A real network should") do
|
|
|
|
tests("return valid vifs") do
|
|
|
|
test("as an array") { network.vifs.kind_of? Array }
|
2014-05-26 09:44:18 -04:00
|
|
|
network.vifs.each { |i|
|
2012-04-02 07:25:03 -04:00
|
|
|
test("and each VIF should be a Fog::Compute::XenServer::VIF") { i.kind_of? Fog::Compute::XenServer::VIF }
|
2014-05-26 09:44:18 -04:00
|
|
|
}
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
2014-05-26 09:44:18 -04:00
|
|
|
tests("return valid PIFs") do
|
2012-04-02 07:25:03 -04:00
|
|
|
networks.each do |network|
|
|
|
|
test("as an array") { network.pifs.kind_of? Array }
|
2014-05-26 09:44:18 -04:00
|
|
|
network.pifs.each { |i|
|
2012-04-02 07:25:03 -04:00
|
|
|
test("and each PIF should be a Fog::Compute::XenServer::PIF") { i.kind_of? Fog::Compute::XenServer::PIF}
|
2014-05-26 09:44:18 -04:00
|
|
|
}
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test("be able to refresh itself") { network.refresh }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-03-26 12:33:39 -04:00
|
|
|
tests("#save") do
|
|
|
|
test 'should create a network' do
|
|
|
|
@net = networks.create :name => 'foo-net'
|
|
|
|
@net.is_a? Fog::Compute::XenServer::Network
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#destroy") do
|
|
|
|
test 'should destroy the network' do
|
|
|
|
@net.destroy
|
|
|
|
(networks.find { |n| n.reference == @net.reference }).nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|