Beispiel #1
0
 def test_args(self, mock_notify):
     ntfy_main([
         '-o', 'foo', 'bar', '-b', 'default', '-t', 'TITLE', 'send', 'test'
     ])
     mock_notify.assert_called_once_with(message='test',
                                         title='TITLE',
                                         foo='bar')
Beispiel #2
0
 def test_args(self, mock_notify):
     ntfy_main(['-o', 'foo', 'bar', '-b', 'default', '-t', 'TITLE', 'send',
                'test'])
     mock_notify.assert_called_once_with(message='test',
                                         title='TITLE',
                                         foo='bar',
                                         retcode=0)
Beispiel #3
0
 def test_prowl(self, mock_post, mock_yamlload):
     mock_yamlload.return_value = {
         'backends': ['prowl'],
         'prowl': {
             'apikey': MagicMock()
         },
     }
     ntfy_main(['send', 'foobar'])
Beispiel #4
0
 def test_simplepush(self, mock_post, mock_yamlload):
     mock_yamlload.return_value = {
         'backends': ['simplepush'],
         'simplepush': {
             'key': MagicMock()
         },
     }
     ntfy_main(['send', 'foobar'])
Beispiel #5
0
 def test_pushover(self, mock_post, mock_yamlload):
     mock_yamlload.return_value = {
         'backends': ['pushover'],
         'pushover': {
             'user_key': MagicMock()
         },
     }
     ntfy_main(['send', 'foobar'])
Beispiel #6
0
 def test_pushbullet(self, mock_post, mock_yamlload):
     mock_yamlload.return_value = {
         'backends': ['pushbullet'],
         'pushbullet': {
             'access_token': MagicMock()
         },
     }
     ntfy_main(['send', 'foobar'])
Beispiel #7
0
 def test_xmpp(self, mock_bot, mock_yamlload):
     mock_yamlload.return_value = {
         'backends': ['xmpp'],
         'xmpp': {
             'jid': 'foo@bar',
             'password': '******',
             'recipient': 'bar@foo'
         }
     }
     ntfy_main(['send', 'foobar'])
Beispiel #8
0
 def test_linux(self, mock_yamlload):
     old_dbus = modules.get('dbus')
     modules['dbus'] = MagicMock()
     try:
         mock_yamlload.return_value = {
             'backends': ['linux'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_dbus is not None:
             modules['dbus'] = old_dbus
Beispiel #9
0
 def test_linux(self, mock_jsonload):
     old_dbus = modules.get('dbus')
     modules['dbus'] = MagicMock()
     try:
         mock_jsonload.return_value = {
             'backends': ['linux'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_dbus is not None:
             modules['dbus'] = old_dbus
Beispiel #10
0
 def test_default(self, mock_bot, mock_yamlload):
     old_dbus = modules.get('dbus')
     modules['dbus'] = MagicMock()
     try:
         mock_yamlload.return_value = {
             'backends': ['default'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_dbus is not None:
             modules['dbus'] = old_dbus
Beispiel #11
0
    def test_instapush(self, mock_yamlload):
        modules['instapush'] = MagicMock()
        modules['instapush'].App().notify.return_value = {'status': 200}

        mock_yamlload.return_value = {
            'backends': ['insta'],
            'insta': {
                'appid': 'appid',
                'secret': 'secret',
                'event_name': 'event',
                'trackers': ['a']
            }
        }
        ntfy_main(['send', 'ms'])
Beispiel #12
0
 def test_default(self, mock_yamlload):
     old_dbus = modules.get('dbus')
     modules['dbus'] = MagicMock()
     try:
         mock_yamlload.return_value = {'backends': ['default'], }
         self.assertEqual(0, ntfy_main(['send', 'foobar']))
     finally:
         if old_dbus is not None:
             modules['dbus'] = old_dbus
Beispiel #13
0
 def test_win32(self, mock_jsonload):
     old_win32api = modules.get('win32api')
     old_win32gui = modules.get('win32gui')
     old_win32con = modules.get('win32con')
     modules['win32api'] = MagicMock()
     modules['win32gui'] = MagicMock()
     modules['win32con'] = MagicMock()
     try:
         mock_jsonload.return_value = {
             'backends': ['win32'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_win32api is not None:
             modules['win32api'] = old_win32api
         if old_win32gui is not None:
             modules['win32gui'] = old_win32gui
         if old_win32con is not None:
             modules['win32con'] = old_win32con
Beispiel #14
0
 def test_darwin(self, mock_yamlload):
     old_foundation = modules.get('Foundation')
     old_objc = modules.get('objc')
     old_appkit = modules.get('AppKit')
     modules['Foundation'] = MagicMock()
     modules['objc'] = MagicMock()
     modules['AppKit'] = MagicMock()
     try:
         mock_yamlload.return_value = {
             'backends': ['darwin'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_foundation is not None:
             modules['Foundation'] = old_foundation
         if old_objc is not None:
             modules['objc'] = old_objc
         if old_appkit is not None:
             modules['AppKit'] = old_appkit
Beispiel #15
0
 def test_win32(self, mock_yamlload):
     old_win32api = modules.get('win32api')
     old_win32gui = modules.get('win32gui')
     old_win32con = modules.get('win32con')
     modules['win32api'] = MagicMock()
     modules['win32gui'] = MagicMock()
     modules['win32con'] = MagicMock()
     try:
         mock_yamlload.return_value = {
             'backends': ['win32'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_win32api is not None:
             modules['win32api'] = old_win32api
         if old_win32gui is not None:
             modules['win32gui'] = old_win32gui
         if old_win32con is not None:
             modules['win32con'] = old_win32con
Beispiel #16
0
 def test_darwin(self, mock_jsonload):
     old_foundation = modules.get('Foundation')
     old_objc = modules.get('objc')
     old_appkit = modules.get('AppKit')
     modules['Foundation'] = MagicMock()
     modules['objc'] = MagicMock()
     modules['AppKit'] = MagicMock()
     try:
         mock_jsonload.return_value = {
             'backends': ['darwin'],
         }
         ntfy_main(['send', 'foobar'])
     finally:
         if old_foundation is not None:
             modules['Foundation'] = old_foundation
         if old_objc is not None:
             modules['objc'] = old_objc
         if old_appkit is not None:
             modules['AppKit'] = old_appkit
Beispiel #17
0
 def test_args(self, mock_notify):
     mock_notify.return_value = None
     self.assertEquals(
         0,
         ntfy_main([
             '-o', 'foo', 'bar', '-b', 'default', '-t', 'TITLE', 'send',
             'test'
         ]))
     mock_notify.assert_called_once_with(message='test',
                                         title='TITLE',
                                         foo='bar',
                                         retcode=0)
Beispiel #18
0
 def test_pushbullet(self, mock_post, mock_jsonload):
     mock_jsonload.return_value = {
         'backends': ['pushbullet'],
         'pushbullet': {'access_token': MagicMock()},
     }
     ntfy_main(['send', 'foobar'])
Beispiel #19
0
 def test_pushover(self, mock_post, mock_jsonload):
     mock_jsonload.return_value = {
         'backends': ['pushover'],
         'pushover': {'user_key': MagicMock()},
     }
     ntfy_main(['send', 'foobar'])