~didrocks/ubuntuone-client/dont-suffer-zg-crash

« back to all changes in this revision

Viewing changes to tests/platform/linux/test_notification.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-01-25 16:42:52 UTC
  • mto: This revision was merged to the branch mainline in revision 64.
  • Revision ID: james.westby@ubuntu.com-20110125164252-rl1pybasx1nsqgoy
Tags: upstream-1.5.3
ImportĀ upstreamĀ versionĀ 1.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ubuntuone.tests.platform.notification - Test User Notification
 
2
#
 
3
# Author: Eric Casteleijn <eric.casteleijn@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
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.
 
10
#
 
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.
 
15
#
 
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."""
 
19
 
 
20
from twisted.trial.unittest import TestCase
 
21
 
 
22
from ubuntuone.status.notification import AbstractNotification
 
23
 
 
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.'
 
28
 
 
29
 
 
30
class FakeNotification(AbstractNotification):
 
31
    """A fake implementation of a notify class."""
 
32
 
 
33
    def __init__(self, application_name=APPLICATION_NAME):
 
34
        self.application_name = application_name
 
35
        self.notifications = []
 
36
 
 
37
    def send_notification(self, title, message, icon=None, append=False):
 
38
        """Fake sending a notification."""
 
39
        self.notifications.append((title, message, icon, append))
 
40
 
 
41
 
 
42
class TestNotification(TestCase):
 
43
    """Notification of the end user."""
 
44
 
 
45
    def setUp(self):
 
46
        self.notification = FakeNotification()
 
47
 
 
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)
 
54
        self.assertEqual(
 
55
            [(TEST_TITLE, TEST_MESSAGE, None, True),
 
56
             (TEST_TITLE, TEST_MESSAGE2, None, True)],
 
57
            self.notification.notifications)