|
|
@ -260,3 +260,34 @@ def test_dbus_plugin(mock_mainloop, mock_byte, mock_bytearray,
|
|
|
|
# Our notification succeeds even though the gi library was not loaded
|
|
|
|
# Our notification succeeds even though the gi library was not loaded
|
|
|
|
assert(obj.notify(title='title', body='body',
|
|
|
|
assert(obj.notify(title='title', body='body',
|
|
|
|
notify_type=apprise.NotifyType.INFO) is True)
|
|
|
|
notify_type=apprise.NotifyType.INFO) is True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Force a global import error
|
|
|
|
|
|
|
|
_session_bus = sys.modules['dbus']
|
|
|
|
|
|
|
|
sys.modules['dbus'] = compile('raise ImportError()', 'dbus', 'exec')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Reload our modules
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.plugins.NotifyDBus'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.plugins'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.Apprise'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create our instance
|
|
|
|
|
|
|
|
obj = apprise.Apprise.instantiate('glib://', suppress_exceptions=False)
|
|
|
|
|
|
|
|
assert(isinstance(obj, apprise.plugins.NotifyDBus) is True)
|
|
|
|
|
|
|
|
obj.duration = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test url() call
|
|
|
|
|
|
|
|
assert(compat_is_basestring(obj.url()) is True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Our notification fail because the dbus library wasn't present
|
|
|
|
|
|
|
|
assert(obj.notify(title='title', body='body',
|
|
|
|
|
|
|
|
notify_type=apprise.NotifyType.INFO) is False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Since playing with the sys.modules is not such a good idea,
|
|
|
|
|
|
|
|
# let's just put it back now :)
|
|
|
|
|
|
|
|
sys.modules['dbus'] = _session_bus
|
|
|
|
|
|
|
|
# Reload our modules
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.plugins.NotifyDBus'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.plugins'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise.Apprise'])
|
|
|
|
|
|
|
|
reload(sys.modules['apprise'])
|
|
|
|