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

* Added VIF model and collection tests

* added network and server wrappers to VIF model
This commit is contained in:
Sergio Rubio 2012-04-02 13:35:49 +02:00
parent 3131e7b9fb
commit 641ebd3fcd
2 changed files with 63 additions and 8 deletions

View file

@ -18,18 +18,20 @@ module Fog
attribute :mac_autogenerated, :aliases => :MAC_autogenerated
attribute :metrics
attribute :mtu, :aliases => :MTU
attribute :network
attribute :__network, :aliases => :network
attribute :status_code
attribute :status_detail
attribute :vm, :aliases => :VM
attribute :__vm, :aliases => :VM
#ignore_attributes :current_operations, :qos_supported_algorithms, :qos_algorithm_params, :qos_algorithm_type, :other_config,
# :runtime_properties
def initialize(attributes={})
@uuid ||= 0
super
def network
connection.networks.get __network
end
def server
connection.servers.get __vm
end
end
end

View file

@ -0,0 +1,53 @@
Shindo.tests('Fog::Compute[:xenserver] | VIF model', ['VIF']) do
vifs = Fog::Compute[:xenserver].vifs
vif = vifs.first
tests('The VIF model should') do
tests('have the action') do
test('reload') { vif.respond_to? 'reload' }
end
tests('have attributes') do
model_attribute_hash = vif.attributes
attributes = [
:reference,
:mac,
:uuid,
:allowed_operations,
:currently_attached,
:device,
:mac_autogenerated,
:metrics,
:mtu,
:__network,
:status_code,
:status_detail,
:__vm
]
tests("The VIF model should respond to") do
attributes.each do |attribute|
test("#{attribute}") { vif.respond_to? attribute }
end
end
tests("The attributes hash should have key") do
attributes.each do |attribute|
test("#{attribute}") { model_attribute_hash.has_key? attribute }
end
end
end
test('be a kind of Fog::Compute::XenServer::VIF') { vif.kind_of? Fog::Compute::XenServer::VIF}
end
tests("A real VIF should") do
tests("return a valid network") do
test("should be a Fog::Compute::XenServer::Network") { vif.network.kind_of? Fog::Compute::XenServer::Network }
end
tests("return valid VIF") do
test("should be a Fog::Compute::XenServer::Server") { vif.server.kind_of? Fog::Compute::XenServer::Server }
end
end
end