def test_send_two_notifications(self):
     """On notification, pynotify receives the proper calls."""
     self._set_up_mock_notify(FAKE_TITLE, FAKE_MESSAGE, ICON_NAME)
     mock_notification = self.mocker.mock()
     self.mocker.result(mock_notification)
     mock_notification.set_hint_int32('transient', int(True))
     mock_notification.show()
     mock_notification.update(
         FAKE_TITLE + '2', FAKE_MESSAGE + '2', ICON_NAME)
     mock_notification.set_hint_int32('transient', int(True))
     mock_notification.show()
     self.mocker.replay()
     notifier = Notification(FAKE_APP_NAME)
     notifier.send_notification(FAKE_TITLE, FAKE_MESSAGE)
     notifier.send_notification(FAKE_TITLE + '2', FAKE_MESSAGE + '2')
 def test_append_notification(self):
     """On notification append, pynotify receives the proper calls."""
     self._set_up_mock_notify(FAKE_TITLE, FAKE_MESSAGE, ICON_NAME)
     mock_notification = self.mocker.mock()
     self.mocker.result(mock_notification)
     mock_notification.set_hint_string('x-canonical-append', '')
     mock_notification.set_hint_int32('transient', int(True))
     mock_notification.show()
     mock_notification.update(FAKE_TITLE, FAKE_APPENDAGE, ICON_NAME)
     mock_notification.set_hint_string('x-canonical-append', '')
     mock_notification.set_hint_int32('transient', int(True))
     mock_notification.show()
     self.mocker.replay()
     notifier = Notification(FAKE_APP_NAME)
     notifier.send_notification(FAKE_TITLE, FAKE_MESSAGE, append=True)
     notifier.send_notification(FAKE_TITLE, FAKE_APPENDAGE, append=True)
class ToggleableNotification(object):
    """A controller for notifications that can be turned off."""

    def __init__(self, notification_switch):
        """Initialize this instance."""
        self.notification_switch = notification_switch
        self.notification = Notification()

    def send_notification(self, *args):
        """Passthru the notification."""
        if self.notification_switch.enabled:
            return self.notification.send_notification(*args)
 def __init__(self, notification_switch):
     """Initialize this instance."""
     self.notification_switch = notification_switch
     self.notification = Notification()