1
# ubuntuone.tests.platform.notification - Test User Notification
3
# Author: Eric Casteleijn <eric.casteleijn@canonical.com>
5
# Copyright 2011 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Module that implements notification of the end user."""
20
from twisted.trial.unittest import TestCase
22
from ubuntuone.status.notification import AbstractNotification
24
APPLICATION_NAME = 'Ubuntu One Tests'
25
TEST_TITLE = 'This is the Title'
26
TEST_MESSAGE = 'This is the body of the message.'
27
TEST_MESSAGE2 = 'This is the body of the second message.'
30
class FakeNotification(AbstractNotification):
31
"""A fake implementation of a notify class."""
33
def __init__(self, application_name=APPLICATION_NAME):
34
self.application_name = application_name
35
self.notifications = []
37
def send_notification(self, title, message, icon=None, append=False):
38
"""Fake sending a notification."""
39
self.notifications.append((title, message, icon, append))
42
class TestNotification(TestCase):
43
"""Notification of the end user."""
46
self.notification = FakeNotification()
48
def test_notifications(self):
49
"""Test the notification."""
50
self.notification.send_notification(
51
TEST_TITLE, TEST_MESSAGE, append=True)
52
self.notification.send_notification(
53
TEST_TITLE, TEST_MESSAGE2, append=True)
55
[(TEST_TITLE, TEST_MESSAGE, None, True),
56
(TEST_TITLE, TEST_MESSAGE2, None, True)],
57
self.notification.notifications)