Mailinglist Archive: yast-commit (1914 mails)

< Previous Next >
[yast-commit] <rest-service> basesystem : added tests for controller and model
  • From: Michal Zugec <mzugec@xxxxxxx>
  • Date: Thu, 27 Aug 2009 14:53:54 +0200
  • Message-id: <E1Mlezq-00042i-Ur@xxxxxxxxxxxxxxxx>
ref: refs/heads/basesystem
commit 9bf0a11cb68e462dd4a031e48b3b536b9f9ec843
Author: Michal Zugec <mzugec@xxxxxxx>
Date: Thu Aug 27 14:53:54 2009 +0200

added tests for controller and model
---
.../test/functional/hostname_controller_test.rb | 21 ++++++++++++++++
plugins/network/test/unit/hostname_test.rb | 25 ++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/plugins/network/test/functional/hostname_controller_test.rb
b/plugins/network/test/functional/hostname_controller_test.rb
new file mode 100644
index 0000000..76d1eba
--- /dev/null
+++ b/plugins/network/test/functional/hostname_controller_test.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
+require 'test/unit'
+require 'rubygems'
+require 'hostname'
+require "scr"
+require 'mocha'
+require File.expand_path( File.join("test","plugin_basic_tests"),
RailsParent.parent )
+
+class HostnameControllerTest < Test::Unit::TestCase
+
+ # this is test only for mocked data - not very useful
+ # we need to extend it to test both model and controller
+ # to extract hostname data from all YaPI map
+ #
+ def test_show
+ Hostname.expects(:find).returns({:name=>'linux', :domain=>'suse.cz'})
+ Hostname.find
+ end
+
+end
+
diff --git a/plugins/network/test/unit/hostname_test.rb
b/plugins/network/test/unit/hostname_test.rb
new file mode 100644
index 0000000..bc45241
--- /dev/null
+++ b/plugins/network/test/unit/hostname_test.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
+
+class HostnameTest < ActiveSupport::TestCase
+
+ RESPONSE_FULL = {
+ 'interfaces'=>{
+ 'eth0'=>{'bootproto'=>'dhcp'},
+ 'eth1'=>{'bootproto'=>'static',
'ipaddr'=>'192.168.3.27/24'}},
+ 'routes'=>{'default'=>'10.20.7.254'},
+ 'dns'=>{'dnsservers'=>'10.20.0.15 10.20.0.8',
'dnsdomains'=>'suse.cz suse.de'},
+ 'hostname'=>{'name'=>'linux', 'domain'=>'suse.cz'}
+ }
+
+ def setup
+ YastService.stubs(:Call).with("YaPI::NETWORK::Read").returns(RESPONSE_FULL)
+ end
+
+ def test_getter
+ hostname=Hostname.find
+ assert_equal("linux", hostname.name)
+ assert_equal("suse.cz", hostname.domain)
+ end
+
+end
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages