diff bitten/tests/notify.py @ 541:2479e2a75afa

`BittenNotifyEmail` objects have state, so the same instance cannot be shared
author mgood
date Mon, 23 Mar 2009 01:15:52 +0000
parents 2cc5457e6610
children cc2383034358
line wrap: on
line diff
--- a/bitten/tests/notify.py
+++ b/bitten/tests/notify.py
@@ -41,36 +41,30 @@
     """unit tests for BittenNotify dispatcher class"""
     def setUp(self):
         BittenNotifyBaseTest.setUp(self)
-        self.notify_was_called = False
-        def notify(build_info):
-            self.notify_was_called = True
-        self.dispatcher = Mock(BittenNotify, self.env,
-                               email=Mock(notify=notify))
+        self.dispatcher = BittenNotify(self.env)
         self.failed_build = Build(self.env, status=Build.FAILURE)
         self.successful_build = Build(self.env, status=Build.SUCCESS)
 
     def test_do_notify_on_failed_build(self):
         self.env.config.set(CONFIG_SECTION, NOTIFY_ON_FAILURE, 'true')
-        self.dispatcher.notify(self.failed_build)
-        self.assertTrue(self.notify_was_called,
+        self.assertTrue(self.dispatcher._should_notify(self.failed_build),
                 'notifier should be called for failed builds.')
 
     def test_do_not_notify_on_failed_build(self):
         self.env.config.set(CONFIG_SECTION, NOTIFY_ON_FAILURE, 'false')
-        self.dispatcher.notify(self.failed_build)
-        self.assertFalse(self.notify_was_called,
+        self.assertFalse(self.dispatcher._should_notify(self.failed_build),
                 'notifier should not be called for failed build.')
 
     def test_do_notify_on_successful_build(self):
         self.env.config.set(CONFIG_SECTION, NOTIFY_ON_SUCCESS, 'true')
         self.dispatcher.notify(self.successful_build)
-        self.assertTrue(self.notify_was_called,
+        self.assertTrue(self.dispatcher._should_notify(self.successful_build),
                 'notifier should be called for successful builds when configured.')
 
     def test_do_not_notify_on_successful_build(self):
         self.env.config.set(CONFIG_SECTION, NOTIFY_ON_SUCCESS, 'false')
         self.dispatcher.notify(self.successful_build)
-        self.assertFalse(self.notify_was_called,
+        self.assertFalse(self.dispatcher._should_notify(self.successful_build),
                 'notifier shouldn\'t be called for successful build.')
 
 
Copyright (C) 2012-2017 Edgewall Software