Files
MIND/tests/reminders_test.py
2023-01-16 23:30:18 +01:00

30 lines
815 B
Python

import unittest
from threading import Thread
from backend.reminders import filter_function, ReminderHandler
class Test_Reminder_Handler(unittest.TestCase):
def test_starting_stopping(self):
context = 'test'
instance = ReminderHandler(context)
self.assertIs(context, instance.context)
self.assertIsInstance(instance.thread, Thread)
self.assertFalse(instance.stop)
with self.assertRaises(RuntimeError):
instance.stop_handling()
self.assertTrue(instance.stop)
def test_filter_function(self):
p = {
'title': 'TITLE',
'text': 'TEXT',
'notification_service_title': 'NOTIFICATION_SERVICE_TITLE'
}
for test_case in ('', 'title', 'service', 'ex'):
self.assertTrue(filter_function(test_case, p))
for test_case in (' ', 'Hello'):
self.assertFalse(filter_function(test_case, p))