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')
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)
def test_prowl(self, mock_post, mock_yamlload): mock_yamlload.return_value = { 'backends': ['prowl'], 'prowl': { 'apikey': MagicMock() }, } ntfy_main(['send', 'foobar'])
def test_simplepush(self, mock_post, mock_yamlload): mock_yamlload.return_value = { 'backends': ['simplepush'], 'simplepush': { 'key': MagicMock() }, } ntfy_main(['send', 'foobar'])
def test_pushover(self, mock_post, mock_yamlload): mock_yamlload.return_value = { 'backends': ['pushover'], 'pushover': { 'user_key': MagicMock() }, } ntfy_main(['send', 'foobar'])
def test_pushbullet(self, mock_post, mock_yamlload): mock_yamlload.return_value = { 'backends': ['pushbullet'], 'pushbullet': { 'access_token': MagicMock() }, } ntfy_main(['send', 'foobar'])
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'])
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
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
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
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'])
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
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
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
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
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
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)
def test_pushbullet(self, mock_post, mock_jsonload): mock_jsonload.return_value = { 'backends': ['pushbullet'], 'pushbullet': {'access_token': MagicMock()}, } ntfy_main(['send', 'foobar'])
def test_pushover(self, mock_post, mock_jsonload): mock_jsonload.return_value = { 'backends': ['pushover'], 'pushover': {'user_key': MagicMock()}, } ntfy_main(['send', 'foobar'])