46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
# Copyright 2019 (c) Anna Schumaker.
|
|
from . import notify
|
|
import unittest
|
|
|
|
class TestNotify(unittest.TestCase):
|
|
def setUp(self):
|
|
self.test_count = 0
|
|
self.test_arg1 = None
|
|
self.test_arg2 = None
|
|
|
|
def on_test1(self, arg1, arg2):
|
|
self.test_count += 1
|
|
def on_test2(self, arg1, arg2):
|
|
self.test_arg1 = arg1
|
|
def on_test3(self, arg1, arg2):
|
|
self.test_arg2 = arg2
|
|
|
|
def test_notify(self):
|
|
self.assertRaises(NotImplementedError, notify.Notify)
|
|
self.assertEqual(notify.Notify.notifications, {})
|
|
notify.Notify.notify_me("on-test", self.on_test1)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ self.on_test1 ]})
|
|
notify.Notify.notify_me("on-test", self.on_test1)
|
|
notify.Notify.notify_me("on-test", self.on_test2)
|
|
notify.Notify.notify_me("on-test", self.on_test3)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ self.on_test1, self.on_test2, self.on_test3 ]})
|
|
|
|
notify.Notify.notify("on-test", "It Worked", "CoolCoolCool")
|
|
self.assertEqual(self.test_count, 1)
|
|
self.assertEqual(self.test_arg1, "It Worked")
|
|
self.assertEqual(self.test_arg2, "CoolCoolCool")
|
|
|
|
notify.Notify.notify("no-cb", "Please", "Don't", "Crash")
|
|
|
|
notify.Notify.notify_cancel("on-test", self.on_test2)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ self.on_test1, self.on_test3 ]})
|
|
notify.Notify.notify_cancel("on-test", self.on_test1)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ self.on_test3 ]})
|
|
notify.Notify.notify_cancel("on-test", self.on_test3)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ ]})
|
|
notify.Notify.notify_cancel("on-test", self.on_test1)
|
|
self.assertEqual(notify.Notify.notifications, {"on-test" : [ ]})
|
|
|
|
notify.Notify.clear()
|
|
self.assertEqual(notify.Notify.notifications, { })
|