Exemple #1
0
    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")
Exemple #2
0
    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, '*****@*****.**')
Exemple #3
0
    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)
Exemple #4
0
 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
Exemple #5
0
    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)
Exemple #6
0
 def is_enabled():
     return bool(NotifiersConfig.get().mail.enabled)
Exemple #7
0
 def is_enabled():
     return bool(NotifiersConfig.get().pushbullet.enabled)
Exemple #8
0
 def __init__(self):
     self.pb = PushBullet(NotifiersConfig.get().pushbullet.token)
Exemple #9
0
    def test_is_enabled_enabled(self):
        NotifiersConfig.get()['mail']['enabled'] = True

        self.assertTrue(MailNotifier.is_enabled())
Exemple #10
0
    def test_is_enabled_disabled(self):
        NotifiersConfig.get()['mail']['enabled'] = False

        self.assertFalse(MailNotifier.is_enabled())
Exemple #11
0
    def test_is_enabled_enabled(self):
        NotifiersConfig.get()['pushbullet']['enabled'] = True

        self.assertTrue(PushbulletNotifier.is_enabled())
Exemple #12
0
    def test_is_enabled_disabled(self):
        NotifiersConfig.get()['pushbullet']['enabled'] = False

        self.assertFalse(PushbulletNotifier.is_enabled())
Exemple #13
0
 def is_enabled():
     if NotifiersConfig.get().mail.enabled:
         return True
     return False
Exemple #14
0
 def is_enabled():
     if NotifiersConfig.get().pushbullet.enabled:
         return True
     return False