diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tc_mauve_configuration.rb | 38 | ||||
-rw-r--r-- | test/tc_mauve_configuration_builders_logger.rb | 7 | ||||
-rw-r--r-- | test/tc_mauve_notification.rb | 10 | ||||
-rw-r--r-- | test/tc_mauve_time.rb | 23 |
4 files changed, 72 insertions, 6 deletions
diff --git a/test/tc_mauve_configuration.rb b/test/tc_mauve_configuration.rb new file mode 100644 index 0000000..bbc1901 --- /dev/null +++ b/test/tc_mauve_configuration.rb @@ -0,0 +1,38 @@ +$:.unshift "../lib/" + +require 'th_mauve' +require 'mauve/configuration' + +class TcMauveConfiguration < Mauve::UnitTest + include Mauve + + def setup + setup_logger + end + + def teardown + teardown_logger + end + + def test_do_parse_range + [ + [[1.0...2.0], 1], + [[1.0...3.0], 1..2], + [[1.0...2.0], 1...2], + [[1.0...2.0, 4.0...7.0], [1, 4..6]], + [[1.0..1.0], 1.0], + [[1.0..2.0], 1.0..2.0], + [[1.0...2.0], 1.0...2.0], + [[1.0..1.0, 4.0..6.0], [1.0, 4.0..6.0]], + [[7.0...24.0, 0.0...7.0], 7..6], + [[6.0...7.0, 0.0...1.0], 6..0, 0...7], + [["x".."z", "a".."c"], "x".."c", "a".."z"] + ].each do |output, *input| + c = Configuration.new + assert_equal(output, c.__send__("do_parse_range",*input)) + end + end + +end + + diff --git a/test/tc_mauve_configuration_builders_logger.rb b/test/tc_mauve_configuration_builders_logger.rb index 2d2bb80..14df0d8 100644 --- a/test/tc_mauve_configuration_builders_logger.rb +++ b/test/tc_mauve_configuration_builders_logger.rb @@ -2,6 +2,7 @@ $:.unshift "../lib/" require 'th_mauve' require 'mauve/configuration_builders/logger' +require 'tempfile' class TcMauveConfigurationBuildersLogger < Mauve::UnitTest @@ -10,6 +11,8 @@ class TcMauveConfigurationBuildersLogger < Mauve::UnitTest def test_load + test_log = Tempfile.new(self.class.to_s) + config=<<EOF logger { default_format "%d [ %l ] [ %12.12c ] %m" @@ -19,7 +22,7 @@ logger { outputter ("file") { trunc false - filename "test.conf" + filename "#{test_log.path}" level DEBUG } @@ -46,7 +49,7 @@ EOF assert_equal("%d [ %l ] [ %12.12c ] %m", outputter.formatter.pattern ) assert_equal(Log4r::DEBUG, outputter.level ) assert_equal(false, outputter.trunc ) - assert_equal("test.conf", outputter.filename ) + assert_equal(test_log.path, outputter.filename ) end def test_levels diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb index 21ff41e..df8fa9b 100644 --- a/test/tc_mauve_notification.rb +++ b/test/tc_mauve_notification.rb @@ -224,6 +224,16 @@ EOF logger_pop end + def test_bank_holiday + time = Time.now + + dr = DuringRunner.new(time) + assert(!dr.send(:bank_holiday?)) + + time.bank_holidays << Date.new(Time.now.year, Time.now.month, Time.now.day) + assert(dr.send(:bank_holiday?)) + end + end class TcMauveNotification < Mauve::UnitTest diff --git a/test/tc_mauve_time.rb b/test/tc_mauve_time.rb index 6e5989b..66cb4f7 100644 --- a/test/tc_mauve_time.rb +++ b/test/tc_mauve_time.rb @@ -16,8 +16,8 @@ class TestMauveTime < Mauve::UnitTest # # Working hours.. # - hour_0 = Time.local(2011,6,6,8,30,0) - hour_1 = Time.local(2011,6,6,9,30,0) + hour_0 = Time.local(2011,6,6,9,0,0) + hour_1 = Time.local(2011,6,6,10,0,0) assert_equal(hour_1, t.in_x_hours(1,"working")) assert_equal(hour_0, t.in_x_hours(0,"working")) @@ -31,7 +31,7 @@ class TestMauveTime < Mauve::UnitTest # Working hours.. # hour_0 = Time.local(2011,6,3,16,45,32) - hour_1 = Time.local(2011,6,6,9,15,32) + hour_1 = Time.local(2011,6,6,9,45,32) assert_equal(hour_1, t.in_x_hours(1,"working")) assert_equal(hour_0, t.in_x_hours(0,"working")) @@ -41,10 +41,25 @@ class TestMauveTime < Mauve::UnitTest x = Time.now assert(!x.bank_holiday?) - x.bank_holidays << Date.new(x.year, x.month, x.day) assert(x.bank_holiday?) end + def test_dead_zone? + x = Time.local(2012,5,2,4,30,0) + assert(x.dead_zone?) + + x = Time.local(2012,5,2,9,30,0) + assert(!x.dead_zone?) + end + + def test_daytime_hours + x = Time.local(2012,5,2,4,30,0) + assert(!x.daytime_hours?) + + x = Time.local(2012,5,2,9,30,0) + assert(x.daytime_hours?) + end + end |