[yast-commit] <rest-service> master : added BackgroundManager testsuite
ref: refs/heads/master commit 6b22e6615011cdede656a45a96a9b4c271f7e1d5 Author: Ladislav Slezak <lslezak@novell.com> Date: Fri Dec 18 09:44:03 2009 +0100 added BackgroundManager testsuite --- webservice/test/unit/background_manager_test.rb | 77 +++++++++++++++++++++++ 1 files changed, 77 insertions(+), 0 deletions(-) diff --git a/webservice/test/unit/background_manager_test.rb b/webservice/test/unit/background_manager_test.rb new file mode 100644 index 0000000..81f0b39 --- /dev/null +++ b/webservice/test/unit/background_manager_test.rb @@ -0,0 +1,77 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class BackgroundManagerTest < ActiveSupport::TestCase + def setup + @bm = BackgroundManager.instance + end + + def test_instance_not_nil + assert_not_equal nil, @bm + end + + def test_background_manager + + # no background progress created yet + assert !@bm.process_running?(:dummy) + assert !@bm.process_finished?(:dummy) + assert_equal nil, @bm.get_progress(:dummy) + assert_equal nil, @bm.get_value(:dummy) + + @bm.update_progress(:dummy) + assert_equal nil, @bm.get_progress(:dummy) + + @bm.update_progress(:dummy) do |s| + s.progress = 10 + end + assert_equal nil, @bm.get_progress(:dummy) + + + # register a process + @bm.add_process(:test) + + assert @bm.process_running?(:test) + assert !@bm.process_finished?(:test) + assert_not_equal nil, @bm.get_progress(:test) + assert_equal 0, @bm.get_progress(:test).progress + assert_equal nil, @bm.get_value(:test) + + + # update progress + pr = 42 + sp = 10 + st = 'testing' + @bm.update_progress(:test) do |p| + p.status = st + p.progress = pr + p.subprogress = sp + end + + assert @bm.process_running?(:test) + assert !@bm.process_finished?(:test) + assert_not_equal nil, @bm.get_progress(:test) + assert_equal st, @bm.get_progress(:test).status + assert_equal pr, @bm.get_progress(:test).progress + assert_equal sp, @bm.get_progress(:test).subprogress + assert_equal nil, @bm.get_value(:test) + + + # finish the process, set a final value + final_value = 'final_value' + @bm.finish_process(:test, final_value) + assert !@bm.process_running?(:test) + assert @bm.process_finished?(:test) + assert_equal nil, @bm.get_progress(:test) + assert_equal final_value, @bm.get_value(:test) + + + # the result is removed after reading + assert_equal nil, @bm.get_value(:test) + assert !@bm.process_running?(:test) + assert !@bm.process_finished?(:test) + + # check the config call + assert_equal Rails.configuration.cache_classes, @bm.background_enabled? + end + + +end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
Ladislav Slezak