Beispiel #1
0
    def test_overwrite_notification(self):
        notification = Notification(3, "A1", "icon", "1", "212", ["dflt"],
                                    1595608250375722891, 1)

        self.dm.add_notification(notification)
        self.assertEqual(len(self.dm.get_context()), len(self.notifications))
        self.assertEqual(len(self.dm.get_context(("A1", ))), 4)
        self.assertIs(self.dm.get_context().best, notification)
        self.assertIs(self.dm.get_context(("A1", )).best, notification)
Beispiel #2
0
class TestNotificaton(unittest.TestCase):

    _notification = Notification(1, "app", "icon", "summary", "body",
                                 ["default"], 1595608250375722880, 1)

    def test_format(self):
        self.assertEqual(
            self._notification.formatted(),
            b"<b>summary</b> <small>app</small>\n<i>body</i>",
        )
Beispiel #3
0
    def test_add_notification(self):
        self.assertEqual(len(self.dm.tree), 7)
        self.assertEqual(len(self.dm.get_context(("A2", ))), 2)
        self.assertIs(self.dm.tree.best, self.notifications[-1])

        notification = Notification(8, "A2", "icon", "1", "212", ["dflt"],
                                    1595608250375722891, 1)

        self.dm.add_notification(notification)
        self.assertEqual(len(self.dm.tree), 8)
        self.assertEqual(len(self.dm.tree.notifications["A2"]), 3)
        self.assertIs(self.dm.get_context().best, notification)
        self.assertIs(self.dm.get_context(("A2", )).best, notification)
Beispiel #4
0
    def __init__(self, *args, **kwargs):
        super(TestDataManager, self).__init__(*args, **kwargs)
        self.notifications = [
            Notification(1, "A3", "icon", "1", "113", ["dflt"],
                         1595608250375722879, 1),
            Notification(2, "A1", "icon", "1", "111", ["dflt"],
                         1595608250375722880, 1),
            Notification(3, "A1", "icon", "2", "121", ["dflt"],
                         1595608250375722881, 1),
            Notification(4, "A1", "icon", "1", "112", ["dflt"],
                         1595608250375722882, 1),
            Notification(5, "A2", "icon", "1", "211", ["dflt"],
                         1595608250375722884, 1),
            Notification(6, "A2", "icon", "2", "212", ["dflt"],
                         1595608250375722885, 1),
            Notification(7, "A1", "icon", "1", "113", ["dflt"],
                         1595608250375722886, 1),
        ]

        self.dm = DataManager([DummyConfig], "/dev/null")
        for notification in self.notifications:
            self.dm.add_notification(notification)