[Ovirt-devel] [PATCH server] validations fix, remove incorrect host uuid validation

Mohammed Morsi
2008-12-19T12:24:12Z

updates to the host model to remove the uuid validation which
should not be enforced by the application. updates to the testing
framework to assert the change
---
 src/app/models/host.rb                      |    3 ---
 src/test/unit/host_browser_identify_test.rb |    8 ++++----
 src/test/unit/host_test.rb                  |    8 ++++----
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/app/models/host.rb b/src/app/models/host.rb
index 08f9282..de060b2 100644
--- a/src/app/models/host.rb
+++ b/src/app/models/host.rb
@@ -54,9 +54,6 @@ class Host < ActiveRecord::Base
   validates_presence_of :hardware_pool_id,
      :message => 'A hardware pool id must be specified.'

-  validates_presence_of :uuid,
-     :message => 'A uuid must be specified.'
-
   validates_presence_of :hostname,
      :message => 'A hostname must be specified.'

diff --git a/src/test/unit/host_browser_identify_test.rb
b/src/test/unit/host_browser_identify_test.rb
index 9f7be1f..a17ea30 100644
--- a/src/test/unit/host_browser_identify_test.rb
+++ b/src/test/unit/host_browser_identify_test.rb
@@ -163,11 +163,11 @@ class HostBrowserIdentifyTest < Test::Unit::TestCase

   # Ensures that the server is fine when no UUID is present.
   #
-  #def test_write_host_info_with_missing_uuid
-    #@host_info['UUID'] = nil
+  def test_write_host_info_with_missing_uuid
+    @host_info['UUID'] = nil

-    #assert_nothing_raised { @browser.write_host_info(@host_info) }
-  #end
+    assert_nothing_raised { @browser.write_host_info(@host_info) }
+  end

   # Ensures that, if the hostname is missing, the server
   # raises an exception.
diff --git a/src/test/unit/host_test.rb b/src/test/unit/host_test.rb
index a7458d2..f311bce 100644
--- a/src/test/unit/host_test.rb
+++ b/src/test/unit/host_test.rb
@@ -29,7 +29,7 @@ class HostTest < Test::Unit::TestCase
          :uuid => 'foobar',
          :hostname => 'foobar',
          :arch => 'x86_64',
-         :hypervisor_type => 'kvm',
+         :hypervisor_type => 'KVM',
          :state => 'available')

       @host.hardware_pool = pools(:corp_com)
@@ -41,10 +41,10 @@ class HostTest < Test::Unit::TestCase
       flunk "Hosts must be associated w/ a hardware pool" if
@host.valid?
   end

-  def test_valid_fails_without_uuid
-       @host.uuid = ''
+  def test_valid_without_uuid
+       @host.uuid = nil

-       flunk "Hosts must be associated w/ a uuid" if @host.valid?
+       flunk "Hosts on't need to be associated w/ a uuid" unless
@host.valid?
   end


--
1.6.0.4