def test_notify(self): NotifiersConfig.get()['pushbullet']['token'] = 'test' pushbullet_notifier = PushbulletNotifier.from_config() self.PushBullet.assert_called_once_with("test") pushbullet_notifier.notify("test", "test") self.PushBullet.return_value.push_note.assert_called_once_with("test", "test")
def test_load_values(self): load_fixture_config() # Pushbullet self.assertEqual(NotifiersConfig.get().pushbullet.enabled, False) self.assertEqual(NotifiersConfig.get().pushbullet.token, "test") # Email self.assertEqual(NotifiersConfig.get().mail.enabled, False) self.assertEqual(NotifiersConfig.get().mail.host, 'smtp.provider.com') self.assertEqual(NotifiersConfig.get().mail.port, 25) self.assertEqual(NotifiersConfig.get().mail.tls, False) self.assertEqual(NotifiersConfig.get().mail.username, '*****@*****.**') self.assertEqual(NotifiersConfig.get().mail.password, 'my_secure_password') self.assertEqual(NotifiersConfig.get().mail.recipient, '*****@*****.**')
def test_email(self): sys.argv = [self.program_name, '--test-mail'] test_function_mock = MagicMock() yatcobot.cli.MailNotifier.test = test_function_mock NotifiersConfig.get()['mail']['enabled'] = True with self.assertRaises(SystemExit): main() self.assertEqual(test_function_mock.call_count, 1)
def __init__(self): self.host = NotifiersConfig.get().mail.host self.port = NotifiersConfig.get().mail.port self.tls = NotifiersConfig.get().mail.tls self.username = NotifiersConfig.get().mail.username self.password = NotifiersConfig.get().mail.password self.recipient = NotifiersConfig.get().mail.recipient
def test_notify(self): NotifiersConfig.get()['mail']['enabled'] = True NotifiersConfig.get()['mail']['host'] = 'test' NotifiersConfig.get()['mail']['port'] = 25 NotifiersConfig.get()['mail']['tls'] = True NotifiersConfig.get()['mail']['username'] = '******' NotifiersConfig.get()['mail']['password'] = '******' NotifiersConfig.get()['mail']['recipient'] = '*****@*****.**' mail_notifier = MailNotifier.from_config() mail_notifier.notify("test", "test") self.smtp.assert_called_once_with('test', 25)
def is_enabled(): return bool(NotifiersConfig.get().mail.enabled)
def is_enabled(): return bool(NotifiersConfig.get().pushbullet.enabled)
def __init__(self): self.pb = PushBullet(NotifiersConfig.get().pushbullet.token)
def test_is_enabled_enabled(self): NotifiersConfig.get()['mail']['enabled'] = True self.assertTrue(MailNotifier.is_enabled())
def test_is_enabled_disabled(self): NotifiersConfig.get()['mail']['enabled'] = False self.assertFalse(MailNotifier.is_enabled())
def test_is_enabled_enabled(self): NotifiersConfig.get()['pushbullet']['enabled'] = True self.assertTrue(PushbulletNotifier.is_enabled())
def test_is_enabled_disabled(self): NotifiersConfig.get()['pushbullet']['enabled'] = False self.assertFalse(PushbulletNotifier.is_enabled())
def is_enabled(): if NotifiersConfig.get().mail.enabled: return True return False
def is_enabled(): if NotifiersConfig.get().pushbullet.enabled: return True return False