[Ovirt-devel] [PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.

Scott Seago sseago at redhat.com
Mon May 18 20:58:32 UTC 2009


Signed-off-by: Scott Seago <sseago at redhat.com>
---
 src/test/functional/host_controller_test.rb        |   41 --------------------
 .../functional/managed_node_configuration_test.rb  |   14 ++++---
 src/test/functional/nic_controller_test.rb         |    8 ----
 src/test/functional/permission_controller_test.rb  |   15 ++++---
 src/test/functional/quota_controller_test.rb       |    2 +-
 src/test/functional/resources_controller_test.rb   |    2 +-
 src/test/functional/storage_controller_test.rb     |    4 +-
 src/test/functional/vm_controller_test.rb          |   26 ++++++------
 src/test/test_helper.rb                            |    3 +
 9 files changed, 36 insertions(+), 79 deletions(-)

diff --git a/src/test/functional/host_controller_test.rb b/src/test/functional/host_controller_test.rb
index 497fe5a..caf198d 100644
--- a/src/test/functional/host_controller_test.rb
+++ b/src/test/functional/host_controller_test.rb
@@ -59,47 +59,6 @@ class HostControllerTest < Test::Unit::TestCase
     assert assigns(:host).valid?
   end
 
-  def test_new
-    get :new, :hardware_pool_id => pools(:default).id
-
-    assert_response :redirect
-    assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id
-  end
-
-  def test_create
-    num_hosts = Host.count
-
-    post :create, :host => {}
-
-    assert_response :redirect
-    assert_redirected_to :controller => 'dashboard'
-
-    assert_equal num_hosts, Host.count
-  end
-
-  def test_edit
-    get :edit, :id => @host_id
-
-    assert_response :redirect
-    assert_redirected_to :action => 'show', :id => @host_id
-
-    assert_not_nil assigns(:host)
-    assert assigns(:host).valid?
-  end
-
-  def test_update
-    post :update, :id => @host_id
-    assert_response :redirect
-    assert_redirected_to :action => 'show', :id => @host_id
-  end
-
-  def test_destroy
-    #FIXME: this controller method does nothing, do we even need it or a test?
-    post :destroy, :id => @host_id
-    assert_response :redirect
-    assert_redirected_to :action => 'show', :id => @host_id
-  end
-
   def test_disable_host
     post :host_action, :action_type => 'disable', :id => @host_id
     assert_response :success
diff --git a/src/test/functional/managed_node_configuration_test.rb b/src/test/functional/managed_node_configuration_test.rb
index b66705e..a0a66e9 100644
--- a/src/test/functional/managed_node_configuration_test.rb
+++ b/src/test/functional/managed_node_configuration_test.rb
@@ -48,7 +48,7 @@ class ManagedNodeConfigurationTest < Test::Unit::TestCase
 
     expected = <<-HERE
 # THIS FILE IS GENERATED!
-ifcfg=#{nic.mac}|breth0|BOOTPROTO=#{nic.boot_protocol}|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=#{nic.mac}|breth0|BOOTPROTO=#{nic.boot_protocol}|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
     HERE
 
@@ -67,7 +67,7 @@ ifcfg=#{nic.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
 
     expected = <<-HERE
 # THIS FILE IS GENERATED!
-ifcfg=#{nic.mac}|breth0|BOOTPROTO=#{nic.boot_protocol}|IPADDR=#{nic.ip_address}|NETMASK=#{nic.netmask}|BROADCAST=#{nic.broadcast}|GATEWAY=#{nic.gateway}|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=#{nic.mac}|breth0|BOOTPROTO=#{nic.boot_protocol}|IPADDR=#{nic.ip_address}|NETMASK=#{nic.netmask}|BROADCAST=#{nic.broadcast}|GATEWAY=#{nic.gateway}|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
     HERE
 
@@ -76,6 +76,8 @@ ifcfg=#{nic.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
       {"#{nic.mac}" => 'eth0'}
     )
 
+    logger.info "expected: #{expected.class}, #{expected.length}, #{expected}"
+    logger.info "result: #{result.class}, #{result.size}, #{result}"
     assert_equal expected, result
   end
 
@@ -87,9 +89,9 @@ ifcfg=#{nic.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
 
     expected = <<-HERE
 # THIS FILE IS GENERATED!
-ifcfg=#{nic1.mac}|breth0|BOOTPROTO=#{nic1.boot_protocol}|IPADDR=#{nic1.ip_address}|NETMASK=#{nic1.netmask}|BROADCAST=#{nic1.broadcast}|GATEWAY=#{nic1.gateway}|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=#{nic1.mac}|breth0|BOOTPROTO=#{nic1.boot_protocol}|IPADDR=#{nic1.ip_address}|NETMASK=#{nic1.netmask}|BROADCAST=#{nic1.broadcast}|GATEWAY=#{nic1.gateway}|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic1.mac}|eth0|BRIDGE=breth0|ONBOOT=yes
-ifcfg=#{nic2.mac}|breth1|BOOTPROTO=#{nic2.boot_protocol}|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=#{nic2.mac}|breth1|BOOTPROTO=#{nic2.boot_protocol}|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic2.mac}|eth1|BRIDGE=breth1|ONBOOT=yes
     HERE
 
@@ -116,7 +118,7 @@ ifcfg=#{nic2.mac}|eth1|BRIDGE=breth1|ONBOOT=yes
 # THIS FILE IS GENERATED!
 bonding=#{bonding.interface_name}
 ifcfg=none|#{bonding.interface_name}|BONDING_OPTS="mode=#{bonding.bonding_type.mode} miimon=100"|BRIDGE=br#{bonding.interface_name}|ONBOOT=yes
-ifcfg=none|br#{bonding.interface_name}|BOOTPROTO=dhcp|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=none|br#{bonding.interface_name}|BOOTPROTO=dhcp|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic1.mac}|eth0|MASTER=#{bonding.interface_name}|SLAVE=yes|ONBOOT=yes
 ifcfg=#{nic2.mac}|eth1|MASTER=#{bonding.interface_name}|SLAVE=yes|ONBOOT=yes
 HERE
@@ -143,7 +145,7 @@ HERE
 # THIS FILE IS GENERATED!
 bonding=#{bonding.interface_name}
 ifcfg=none|#{bonding.interface_name}|BONDING_OPTS="mode=#{bonding.bonding_type.mode} miimon=100"|BRIDGE=br#{bonding.interface_name}|ONBOOT=yes
-ifcfg=none|br#{bonding.interface_name}|BOOTPROTO=#{bonding.boot_protocol}|TYPE=bridge|PEERDNS=no|ONBOOT=yes
+ifcfg=none|br#{bonding.interface_name}|BOOTPROTO=#{bonding.boot_protocol}|TYPE=Bridge|PEERDNS=no|ONBOOT=yes
 ifcfg=#{nic1.mac}|eth0|MASTER=#{bonding.interface_name}|SLAVE=yes|ONBOOT=yes
 ifcfg=#{nic2.mac}|eth1|MASTER=#{bonding.interface_name}|SLAVE=yes|ONBOOT=yes
 HERE
diff --git a/src/test/functional/nic_controller_test.rb b/src/test/functional/nic_controller_test.rb
index 68ea3f9..59183ba 100644
--- a/src/test/functional/nic_controller_test.rb
+++ b/src/test/functional/nic_controller_test.rb
@@ -43,12 +43,4 @@ class NicControllerTest < Test::Unit::TestCase
     assert_not_nil assigns(:nic)
     assert assigns(:nic).valid?
   end
-
-  def test_new
-    get :new, :host_id => pools(:default).id
-
-    assert_response :redirect
-    assert_redirected_to :controller => 'host', :action => 'show', :id => pools(:default).id
-
-  end
 end
diff --git a/src/test/functional/permission_controller_test.rb b/src/test/functional/permission_controller_test.rb
index f5aa4a9..0885890 100644
--- a/src/test/functional/permission_controller_test.rb
+++ b/src/test/functional/permission_controller_test.rb
@@ -64,16 +64,17 @@ class PermissionControllerTest < Test::Unit::TestCase
 
   def test_destroy
     post :destroy, :id => @permission_id
-    assert_response :redirect
-    assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id
-    assert_equal "<strong>ovirtadmin</strong> permissions were revoked successfully" , flash[:notice]
+
+    assert_response :success
+    json = ActiveSupport::JSON.decode(@response.body)
+    assert_equal "Permission record was successfully deleted.", json['alert']
   end
 
   def test_no_perms_to_destroy
-    post :destroy, :id => permissions(:ovirtadmin_corp_com_qa_pool).id
-    assert_response :redirect
-    assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:corp_com_qa).id
-    assert_equal "You do not have permission to delete this permission record" , flash[:notice]
+    post :destroy, :id => permissions(:ovirtadmin_corp_com_qa_pool).id, :format => "json"
+    assert_response :success
+    json = ActiveSupport::JSON.decode(@response.body)
+    assert_equal 'You have insufficient privileges to perform action.', json['alert']
   end
 
   #FIXME: write the code to make this a real test!
diff --git a/src/test/functional/quota_controller_test.rb b/src/test/functional/quota_controller_test.rb
index b8f78e6..1496652 100644
--- a/src/test/functional/quota_controller_test.rb
+++ b/src/test/functional/quota_controller_test.rb
@@ -93,7 +93,7 @@ class QuotaControllerTest < Test::Unit::TestCase
     post :destroy, :id => quotas(:corp_com_dev_quota).id, :format => "json"
     assert_response :success
     json = ActiveSupport::JSON.decode(@response.body)
-    assert_equal 'You do not have permission to create or modify this item ', json['alert']
+    assert_equal 'You have insufficient privileges to perform action.', json['alert']
   end
 
   #FIXME: write the code to make this a real test!
diff --git a/src/test/functional/resources_controller_test.rb b/src/test/functional/resources_controller_test.rb
index 976e2d1..34c6554 100644
--- a/src/test/functional/resources_controller_test.rb
+++ b/src/test/functional/resources_controller_test.rb
@@ -71,7 +71,7 @@ class ResourcesControllerTest < ActionController::TestCase
     post :destroy, :id => pools(:corp_com_production_vmpool).id
     assert_response :success
     json = ActiveSupport::JSON.decode(@response.body)
-    assert_equal 'Virtual Machine Pool was successfully deleted.', json['alert']
+    assert_equal 'Pool was successfully deleted.', json['alert']
   end
 
 end
diff --git a/src/test/functional/storage_controller_test.rb b/src/test/functional/storage_controller_test.rb
index 66326d9..fcf0293 100644
--- a/src/test/functional/storage_controller_test.rb
+++ b/src/test/functional/storage_controller_test.rb
@@ -67,7 +67,7 @@ class StorageControllerTest < Test::Unit::TestCase
     assert_response :success
     assert_template 'new'
 
-    assert_not_nil assigns(:storage_pools)
+    assert_not_nil assigns(:storage_types)
   end
 
   def test_create_storage_controller
@@ -107,7 +107,7 @@ class StorageControllerTest < Test::Unit::TestCase
     xml_http_request :post, :destroy, :id => storage_pools(:corp_com_dev_nfs_ovirtnfs).id, :format => "json"
     assert_response :success
     json = ActiveSupport::JSON.decode(@response.body)
-    assert_equal 'You do not have permission to create or modify this item ', json['alert']
+    assert_equal 'You have insufficient privileges to perform action.', json['alert']
   end
 
   #FIXME: write the code to make this a real test!
diff --git a/src/test/functional/vm_controller_test.rb b/src/test/functional/vm_controller_test.rb
index c7769dd..a059c50 100644
--- a/src/test/functional/vm_controller_test.rb
+++ b/src/test/functional/vm_controller_test.rb
@@ -32,9 +32,10 @@ class VmControllerTest < Test::Unit::TestCase
     @response   = ActionController::TestResponse.new
 
     @vm_id = vms(:production_httpd_vm).id
-    @default_pool = pools(:default)
+    @vm_pool = pools(:corp_com_production_vmpool)
   end
 
+
   def test_show
     get :show, :id => @vm_id
 
@@ -46,23 +47,22 @@ class VmControllerTest < Test::Unit::TestCase
   end
 
   def test_new
-    get :new, :hardware_pool_id => @default_pool.id, :format => "json"
-    json = ActiveSupport::JSON.decode(@response.body)
-    assert_equal 'You do not have permission to create or modify this item ', json['alert']
-    assert_not_nil assigns(:vm)
+    get :new, :vm_resource_pool_id => @vm_pool.id
+    assert_response :success
+    assert_template 'new'
+    assert assigns(:vm)
   end
 
   def test_create
     num_vms = Vm.count
 
-    post :create, :vm_resource_pool_name => 'foobar',
-      :hardware_pool_id => @default_pool.id,
-      :vm => { :uuid => 'f43b298c-1e65-46fa-965f-0f6fb9ffaa10',
-                :description =>     'descript',
-                :num_vcpus_allocated => 4,
-                :memory_allocated => 262144,
-                :vnic_mac_addr => 'AA:BB:CC:DD:EE:FF',
-                :boot_device => 'network' }
+    post :create, :vm => { :uuid => 'f43b298c-1e65-46fa-965f-0f6fb9ffaa10',
+               :vm_resource_pool_id => @vm_pool.id,
+               :description =>     'descript',
+               :num_vcpus_allocated => 4,
+               :memory_allocated => 262144,
+               :vnic_mac_addr => 'AA:BB:CC:DD:EE:FF',
+               :boot_device => 'network' }
 
     assert_response :success
 
diff --git a/src/test/test_helper.rb b/src/test/test_helper.rb
index 7988b86..fc84648 100644
--- a/src/test/test_helper.rb
+++ b/src/test/test_helper.rb
@@ -44,4 +44,7 @@ class Test::Unit::TestCase
   self.use_instantiated_fixtures  = false
 
   # Add more helper methods to be used by all tests here...
+  def logger
+    RAILS_DEFAULT_LOGGER
+  end
 end
-- 
1.6.0.6




More information about the ovirt-devel mailing list