Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Added VBD Shindo tests

* added server wrapper to VBD model
  • Loading branch information...
commit 19b927ba4fd04ac8b847eebbafc25ce9a81cf8f5 1 parent 6069997
@rubiojr rubiojr authored
View
16 lib/fog/xenserver/models/compute/vbd.rb
@@ -13,24 +13,20 @@ class VBD < Fog::Model
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
49 tests/xenserver/models/compute/vbd_tests.rb
@@ -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
22 tests/xenserver/models/compute/vbds_tests.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.