diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-27 11:12:27 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-27 11:12:27 +0100 |
commit | dada535a41cba45be0eff77381d6c7e19ab49f51 (patch) | |
tree | f33ab8706c38f278fbdec539e69874d72a9e1b74 /test/tc_mauve_notification.rb | |
parent | ffb9ad5713f0f7b895ec142028abae16d824e3b9 (diff) |
Added better time-based people list polling, and added a "calendar" method to
the config to easily generate Procs to call for people_lists.
Diffstat (limited to 'test/tc_mauve_notification.rb')
-rw-r--r-- | test/tc_mauve_notification.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb index 7a71c47..21ff41e 100644 --- a/test/tc_mauve_notification.rb +++ b/test/tc_mauve_notification.rb @@ -7,17 +7,22 @@ require 'mauve/configuration' require 'mauve/configuration_builder' require 'mauve/configuration_builders' require 'mauve/mauve_time' +require 'webmock' class TcMauveDuringRunner < Mauve::UnitTest include Mauve + include WebMock::API def setup super setup_database + WebMock.disable_net_connect! end def teardown + WebMock.reset! + WebMock.allow_net_connect! teardown_database super end @@ -187,6 +192,38 @@ EOF assert(!dr.send(:no_one_in, "not empty")) end + def test_no_one_in_with_calendar + config=<<EOF +bytemark_calendar_url "http://localhost" +person "test1" +person "test2" + +people_list "support", calendar("support_shift") +EOF + + Configuration.current = ConfigurationBuilder.parse(config) + + stub_request(:get, "http://localhost/api/attendees/support_shift/2011-08-01T00:00:00"). + to_return(:status => 200, :body => YAML.dump(%w(test1 test2))) + + stub_request(:get, "http://localhost/api/attendees/support_shift/2011-08-01T00:05:00"). + to_return(:status => 200, :body => YAML.dump([])) + + dr = DuringRunner.new(Time.now) + assert(!dr.send(:no_one_in, "support")) + + # advance by 5 minutes, and try again -- we should get the same answer. + Timecop.freeze(Time.now + 5.minutes) + assert(!dr.send(:no_one_in, "support")) + + # However a new runner should return true. + dr = DuringRunner.new(Time.now) + assert(dr.send(:no_one_in, "support")) + # + # We expect a warning about an empty list. + logger_pop + end + end class TcMauveNotification < Mauve::UnitTest |