Skip to content

Commit

Permalink
Adding tests for attributes on Models
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Jul 4, 2014
1 parent 659d87f commit 74b8f50
Show file tree
Hide file tree
Showing 33 changed files with 1,308 additions and 9 deletions.
9 changes: 0 additions & 9 deletions test/fog-xenserver/fog_test.rb

This file was deleted.

32 changes: 32 additions & 0 deletions test/fog/compute/xen_server/models/blob_test.rb
@@ -0,0 +1,32 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::Blob do
let(:blob_class) do
class Fog::Compute::XenServer::Models::Blob
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::Blob
end

it 'should return the unique id' do
blob_class.read_identity.must_equal(:reference)
end

it 'should have 8 attributes' do
blob_class.attributes.must_equal([ :reference,
:description,
:last_updated,
:mime_type,
:name,
:public,
:size,
:uuid ])
end

it 'should have 2 aliases' do
blob_class.aliases.must_equal({ :name_description => :description,
:name_label => :name })
end
end
33 changes: 33 additions & 0 deletions test/fog/compute/xen_server/models/bond_test.rb
@@ -0,0 +1,33 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::Bond do
let(:bond_class) do
class Fog::Compute::XenServer::Models::Bond
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::Bond
end

it 'should return the unique id' do
bond_class.read_identity.must_equal(:reference)
end

it 'should have 6 attributes' do
bond_class.attributes.must_equal([ :reference,
:links_up,
:__master,
:mode,
:other_config,
:__primary_slave,
:properties,
:__slaves, :uuid ])
end

it 'should have 3 aliases' do
bond_class.aliases.must_equal({ :master => :__master,
:primary_slave => :__primary_slave,
:slaves => :__slaves })
end
end
29 changes: 29 additions & 0 deletions test/fog/compute/xen_server/models/console_test.rb
@@ -0,0 +1,29 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::Console do
let(:console_class) do
class Fog::Compute::XenServer::Models::Console
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::Console
end

it 'should return the unique id' do
console_class.read_identity.must_equal(:reference)
end

it 'should have 6 attributes' do
console_class.attributes.must_equal([ :reference,
:location,
:other_config,
:protocol,
:uuid,
:__vm ])
end

it 'should have 1 alias' do
console_class.aliases.must_equal({ :VM => :__vm })
end
end
29 changes: 29 additions & 0 deletions test/fog/compute/xen_server/models/crash_dump_test.rb
@@ -0,0 +1,29 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::CrashDump do
let(:crash_dump_class) do
class Fog::Compute::XenServer::Models::CrashDump
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::CrashDump
end

it 'should return the unique id' do
crash_dump_class.read_identity.must_equal(:reference)
end

it 'should have 6 attributes' do
crash_dump_class.attributes.must_equal([ :reference,
:other_config,
:uuid,
:__vdi,
:__vm ])
end

it 'should have 2 aliases' do
crash_dump_class.aliases.must_equal({ :VDI => :__vdi,
:VM => :__vm })
end
end
26 changes: 26 additions & 0 deletions test/fog/compute/xen_server/models/dr_task_test.rb
@@ -0,0 +1,26 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::DrTask do
let(:dr_task_class) do
class Fog::Compute::XenServer::Models::DrTask
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::DrTask
end

it 'should return the unique id' do
dr_task_class.read_identity.must_equal(:reference)
end

it 'should have 3 attributes' do
dr_task_class.attributes.must_equal([ :reference,
:__introduced_srs,
:uuid ])
end

it 'should have 1 alias' do
dr_task_class.aliases.must_equal({ :introduced_SRs => :__introduced_srs })
end
end
35 changes: 35 additions & 0 deletions test/fog/compute/xen_server/models/gpu_group_test.rb
@@ -0,0 +1,35 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::GpuGroup do
let(:gpu_group_class) do
class Fog::Compute::XenServer::Models::GpuGroup
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::GpuGroup
end

it 'should return the unique id' do
gpu_group_class.read_identity.must_equal(:reference)
end

it 'should have 8 attributes' do
gpu_group_class.attributes.must_equal([ :reference,
:description,
:gpu_types,
:name,
:other_config,
:__pgpus,
:uuid,
:__vgpus ])
end

it 'should have 5 aliases' do
gpu_group_class.aliases.must_equal({ :GPU_types => :gpu_types,
:name_description => :description,
:name_label => :name,
:PGPUs => :__pgpus,
:VGPUs => :__vgpus })
end
end
36 changes: 36 additions & 0 deletions test/fog/compute/xen_server/models/guest_metrics_test.rb
@@ -0,0 +1,36 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::GuestMetrics do
let(:guest_metrics_class) do
class Fog::Compute::XenServer::Models::GuestMetrics
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::GuestMetrics
end

it 'should return the unique id' do
guest_metrics_class.read_identity.must_equal(:reference)
end

it 'should have 12 attributes' do
guest_metrics_class.attributes.must_equal([ :reference,
:disk,
:last_updated,
:live,
:memory,
:networks,
:os_version,
:other,
:other_config,
:pv_drivers_up_to_date,
:pv_drivers_version,
:uuid ])
end

it 'should have 2 aliases' do
guest_metrics_class.aliases.must_equal({ :PV_drivers_up_to_date => :pv_drivers_up_to_date,
:PV_drivers_version => :pv_drivers_version })
end
end
38 changes: 38 additions & 0 deletions test/fog/compute/xen_server/models/host_cpu_test.rb
@@ -0,0 +1,38 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::HostCpu do
let(:host_cpu_class) do
class Fog::Compute::XenServer::Models::HostCpu
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::HostCpu
end

it 'should return the unique id' do
host_cpu_class.read_identity.must_equal(:reference)
end

it 'should have 14 attributes' do
host_cpu_class.attributes.must_equal([ :reference,
:family,
:features,
:flags,
:__host,
:model,
:model_name,
:number,
:other_config,
:speed,
:stepping,
:utilisation,
:uuid,
:vendor ])
end

it 'should have 2 aliases' do
host_cpu_class.aliases.must_equal({ :host => :__host,
:modelname => :model_name })
end
end
29 changes: 29 additions & 0 deletions test/fog/compute/xen_server/models/host_crash_dump_test.rb
@@ -0,0 +1,29 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::HostCrashDump do
let(:host_crash_dump_class) do
class Fog::Compute::XenServer::Models::HostCrashDump
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::HostCrashDump
end

it 'should return the unique id' do
host_crash_dump_class.read_identity.must_equal(:reference)
end

it 'should have 6 attributes' do
host_crash_dump_class.attributes.must_equal([ :reference,
:__host,
:other_config,
:size,
:timestamp,
:uuid ])
end

it 'should have 1 alias' do
host_crash_dump_class.aliases.must_equal({ :host => :__host })
end
end
30 changes: 30 additions & 0 deletions test/fog/compute/xen_server/models/host_metrics_test.rb
@@ -0,0 +1,30 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::HostMetrics do
let(:host_metrics_class) do
class Fog::Compute::XenServer::Models::HostMetrics
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::HostMetrics
end

it 'should return the unique id' do
host_metrics_class.read_identity.must_equal(:reference)
end

it 'should have 7 attributes' do
host_metrics_class.attributes.must_equal([ :reference,
:last_updated,
:live,
:memory_free,
:memory_total,
:other_config,
:uuid ])
end

it "shouldn't have aliases" do
host_metrics_class.aliases.must_equal({})
end
end
37 changes: 37 additions & 0 deletions test/fog/compute/xen_server/models/host_patch_test.rb
@@ -0,0 +1,37 @@
require 'minitest_helper'

describe Fog::Compute::XenServer::Models::HostPatch do
let(:host_patch_class) do
class Fog::Compute::XenServer::Models::HostPatch
def self.read_identity
instance_variable_get('@identity')
end
end
Fog::Compute::XenServer::Models::HostPatch
end

it 'should return the unique id' do
host_patch_class.read_identity.must_equal(:reference)
end

it 'should have 11 attributes' do
host_patch_class.attributes.must_equal([ :reference,
:applied,
:description,
:__host,
:name,
:other_config,
:__pool_patch,
:size,
:timestamp_applied,
:uuid,
:version ])
end

it 'should have 4 aliases' do
host_patch_class.aliases.must_equal({ :host => :__host,
:name_description => :description,
:name_label => :name,
:pool_patch => :__pool_patch })
end
end

0 comments on commit 74b8f50

Please sign in to comment.