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

* Added VBD Shindo tests

* added server wrapper to VBD model
This commit is contained in:
Sergio Rubio 2012-04-02 13:48:04 +02:00
parent 606999764e
commit 19b927ba4f
3 changed files with 77 additions and 10 deletions

View file

@ -13,24 +13,20 @@ module Fog
attribute :uuid
attribute :currently_attached
attribute :reserved
attribute :__vdi, :aliases => :VDI
attribute :vm, :aliases => :VM
attribute :__vdi, :aliases => :VDI
attribute :__vm, :aliases => :VM
attribute :device
attribute :status_detail
attribute :type
attribute :userdevice
#ignore_attributes :current_operations, :qos_supported_algorithms, :qos_algorithm_params, :qos_algorithm_type, :other_config,
# :runtime_properties
def initialize(attributes={})
super
end
def vdi
#Fog::Compute::XenServer::VDI.new(connection.get_record( __vdi, 'VDI' ))
connection.vdis.get __vdi
end
def server
connection.servers.get __vm
end
end

View file

@ -0,0 +1,49 @@
Shindo.tests('Fog::Compute[:xenserver] | VBD model', ['VBD']) do
vbds = Fog::Compute[:xenserver].vbds
vbd = vbds.first
tests('The VBD model should') do
tests('have the action') do
test('reload') { vbd.respond_to? 'reload' }
end
tests('have attributes') do
model_attribute_hash = vbd.attributes
attributes = [
:reference,
:uuid,
:currently_attached,
:__vdi,
:__vm,
:device,
:status_detail,
:type,
:userdevice
]
tests("The VBD model should respond to") do
attributes.each do |attribute|
test("#{attribute}") { vbd.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::VBD') { vbd.kind_of? Fog::Compute::XenServer::VBD}
end
tests("A real VBD should") do
tests("return a valid VDI") do
test("should be a Fog::Compute::XenServer::VDI") { vbd.vdi.kind_of? Fog::Compute::XenServer::VDI }
end
tests("return valid Server") do
test("should be a Fog::Compute::XenServer::Server") { vbd.server.kind_of? Fog::Compute::XenServer::Server }
end
end
end

View file

@ -0,0 +1,22 @@
Shindo.tests('Fog::Compute[:xenserver] | VBDs collection', ['vbds']) do
conn = Fog::Compute[:xenserver]
tests('The vbds collection') do
vbds = conn.vbds.all
test('should not be empty') { !vbds.empty? }
test('should be a kind of Fog::Compute::XenServer::Vbds') { vbds.kind_of? Fog::Compute::XenServer::Vbds }
tests('should be able to reload itself').succeeds { vbds.reload }
tests('should be able to get a model') do
tests('by reference').succeeds {
vbds.get(vbds.first.reference).is_a? Fog::Compute::XenServer::VBD
}
end
end
end