code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_apprise_multi_config_entries(tmpdir): """ API: AppriseConfig basic multi-adding functionality """ # temporary file to work with t = tmpdir.mkdir("apprise-multi-add").join("apprise") buf = """ good://hostname """ t.write(buf) # temporary empty file to work with te =...
API: AppriseConfig basic multi-adding functionality
test_apprise_multi_config_entries
python
caronc/apprise
test/test_apprise_config.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_config.py
BSD-2-Clause
def test_config_base_parse_yaml_file04(tmpdir): """ API: ConfigBase.parse_yaml_file (#4) Test the always keyword """ t = tmpdir.mkdir("always-keyword").join("apprise.yml") t.write("""urls: - pover://nsisxnvnqixq39t0cw54pxieyvtdd9@2jevtmstfg5a7hfxndiybasttxxfku: - tag: test1,always - po...
API: ConfigBase.parse_yaml_file (#4) Test the always keyword
test_config_base_parse_yaml_file04
python
caronc/apprise
test/test_apprise_config.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_config.py
BSD-2-Clause
def test_apprise_trans_windows_users_win(mock_getlocale): """ API: Apprise() Windows Locale Testing (Win version) """ # Set- our gettext.locale() return value mock_getlocale.return_value = ('fr_CA', 'UTF-8') with mock.patch( 'ctypes.windll.kernel32.GetUserDefaultUILanguage') as ui...
API: Apprise() Windows Locale Testing (Win version)
test_apprise_trans_windows_users_win
python
caronc/apprise
test/test_apprise_translations.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_translations.py
BSD-2-Clause
def test_apprise_trans_windows_users_nux(mock_getlocale): """ API: Apprise() Windows Locale Testing (Nux version) """ # Set- our gettext.locale() return value mock_getlocale.return_value = ('fr_CA', 'UTF-8') # Emulate a windows environment windll = mock.Mock() setattr(ctypes, 'windll'...
API: Apprise() Windows Locale Testing (Nux version)
test_apprise_trans_windows_users_nux
python
caronc/apprise
test/test_apprise_translations.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_translations.py
BSD-2-Clause
def test_detect_language_using_env(mock_getlocale): """ Test the reading of information from an environment variable """ # Set- our gettext.locale() return value mock_getlocale.return_value = ('en_CA', 'UTF-8') # The below accesses the windows fallback code and fail # then it will resort t...
Test the reading of information from an environment variable
test_detect_language_using_env
python
caronc/apprise
test/test_apprise_translations.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_translations.py
BSD-2-Clause
def test_apprise_trans_gettext_missing(tmpdir): """ Verify we can still operate without the gettext library """ # remove gettext from our system enviroment del sys.modules["gettext"] # Make our new path to a fake gettext (used to over-ride real one) # have it fail right out of the gate ...
Verify we can still operate without the gettext library
test_apprise_trans_gettext_missing
python
caronc/apprise
test/test_apprise_translations.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_translations.py
BSD-2-Clause
def create_hook(tdir, cache=True, on="valid1"): """ Just a temporary hook creation tool for writing a working notify hook """ tdir.write(cleandoc(""" from apprise.decorators import notify # this is a good hook but burried in hidden directory which won't # be acce...
Just a temporary hook creation tool for writing a working notify hook
create_hook
python
caronc/apprise
test/test_apprise_utils.py
https://github.com/caronc/apprise/blob/master/test/test_apprise_utils.py
BSD-2-Clause
def iter_content(self, chunk_size=1024): """Lazy function (generator) to read a file piece by piece. Default chunk size: 1k.""" while True: self._keepalive_chunk_ref += 1 if 16 % self._keepalive_chunk_ref == 0: # Yield a keep-alive...
Lazy function (generator) to read a file piece by piece. Default chunk size: 1k.
iter_content
python
caronc/apprise
test/test_attach_http.py
https://github.com/caronc/apprise/blob/master/test/test_attach_http.py
BSD-2-Clause
def test_config_base_discord_bug_report_01(): """ API: ConfigBase.config_parse user feedback A Discord report that a tag was not correctly assigned to a URL when presented in the following format urls: - json://myhost: - tag: test userid: test """ result,...
API: ConfigBase.config_parse user feedback A Discord report that a tag was not correctly assigned to a URL when presented in the following format urls: - json://myhost: - tag: test userid: test
test_config_base_discord_bug_report_01
python
caronc/apprise
test/test_config_base.py
https://github.com/caronc/apprise/blob/master/test/test_config_base.py
BSD-2-Clause
def test_yaml_vs_text_tagging(): """ API: ConfigBase YAML vs TEXT tagging """ yaml_result, _ = ConfigBase.config_parse_yaml(""" urls: - mailtos://lead2gold:yesqbrulvaelyxve@gmail.com: tag: mytag """) assert yaml_result text_result, _ = ConfigBase.config_parse_text(""" ...
API: ConfigBase YAML vs TEXT tagging
test_yaml_vs_text_tagging
python
caronc/apprise
test/test_config_base.py
https://github.com/caronc/apprise/blob/master/test/test_config_base.py
BSD-2-Clause
def test_conversion_html_to_text(): """conversion: Test HTML to plain text """ def to_html(body): """ A function to simply html conversion tests """ return convert_between(NotifyFormat.HTML, NotifyFormat.TEXT, body) assert to_html("No HTML code here.") == "No HTML code ...
conversion: Test HTML to plain text
test_conversion_html_to_text
python
caronc/apprise
test/test_conversion.py
https://github.com/caronc/apprise/blob/master/test/test_conversion.py
BSD-2-Clause
def test_conversion_text_to(): """conversion: Test Text to all types """ response = convert_between( NotifyFormat.TEXT, NotifyFormat.HTML, "<title>Test Message</title><body>Body</body>") assert response == \ '&lt;title&gt;Test&nbsp;Message&lt;/title&gt;&lt;body&gt;Body&lt;'\ ...
conversion: Test Text to all types
test_conversion_text_to
python
caronc/apprise
test/test_conversion.py
https://github.com/caronc/apprise/blob/master/test/test_conversion.py
BSD-2-Clause
def thread_test(result, no): """ Load our apprise object with valid URLs and store our result """ apobj = Apprise() result[no] = apobj.add('json://localhost') and \ apobj.add('form://localhost') and \ apobj.add('xml://localhost')
Load our apprise object with valid URLs and store our result
thread_test
python
caronc/apprise
test/test_notification_manager.py
https://github.com/caronc/apprise/blob/master/test/test_notification_manager.py
BSD-2-Clause
def test_persistent_storage_asset(tmpdir): """ Tests the Apprise Asset Object when setting the Persistent Store """ asset = AppriseAsset(storage_path=str(tmpdir)) assert asset.storage_path == str(tmpdir) assert asset.storage_mode is PersistentStoreMode.AUTO # If there is no storage path, w...
Tests the Apprise Asset Object when setting the Persistent Store
test_persistent_storage_asset
python
caronc/apprise
test/test_persistent_store.py
https://github.com/caronc/apprise/blob/master/test/test_persistent_store.py
BSD-2-Clause
def test_persistent_custom_io(tmpdir): """ Test reading and writing custom files """ # Initialize it for memory only pc = PersistentStore(path=str(tmpdir)) with pytest.raises(AttributeError): pc.open('!invalid#-Key') # We can't open the file as it does not exist with pytest.ra...
Test reading and writing custom files
test_persistent_custom_io
python
caronc/apprise
test/test_persistent_store.py
https://github.com/caronc/apprise/blob/master/test/test_persistent_store.py
BSD-2-Clause
def test_persistent_storage_disk_prune(tmpdir): """ General testing of a Persistent Store prune calls """ # Persistent Storage Initialization pc = PersistentStore( path=str(tmpdir), namespace='t01', mode=PersistentStoreMode.FLUSH) # Store some data assert pc.write(b'data-t01') is Tr...
General testing of a Persistent Store prune calls
test_persistent_storage_disk_prune
python
caronc/apprise
test/test_persistent_store.py
https://github.com/caronc/apprise/blob/master/test/test_persistent_store.py
BSD-2-Clause
def test_persistent_storage_disk_changes(tmpdir): """ General testing of a Persistent Store with underlining disk changes """ # Create a garbage file in place of where the namespace should be tmpdir.join('t01').write('0' * 1024) # Persistent Storage Initialization where namespace directory now...
General testing of a Persistent Store with underlining disk changes
test_persistent_storage_disk_changes
python
caronc/apprise
test/test_persistent_store.py
https://github.com/caronc/apprise/blob/master/test/test_persistent_store.py
BSD-2-Clause
def dbus_environment(mocker): """ Fixture to provide a mocked Dbus environment to test case functions. """ interface_mock = mocker.patch('dbus.Interface', spec=True, Notify=Mock()) mocker.patch('dbus.SessionBus', spec=True, **{"get_object.return_val...
Fixture to provide a mocked Dbus environment to test case functions.
dbus_environment
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_general_success(mocker, dbus_glib_environment): """ NotifyDBus() general tests Test class loading using different arguments, provided via URL. """ # Create our instance (identify all supported types) obj = apprise.Apprise.instantiate('dbus://', suppress_exceptions=False) ...
NotifyDBus() general tests Test class loading using different arguments, provided via URL.
test_plugin_dbus_general_success
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_missing_icon(mocker, dbus_glib_environment): """ Test exception when loading icon; the notification will still be sent. """ # Inject error when loading icon. gi = importlib.import_module("gi") gi.repository.GdkPixbuf.Pixbuf.new_from_file.side_effect = \ AttributeErr...
Test exception when loading icon; the notification will still be sent.
test_plugin_dbus_missing_icon
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_gi_missing(dbus_glib_environment): """ Verify notification succeeds even if the `gi` package is not available. """ # Make `require_version` function raise an ImportError. gi = importlib.import_module("gi") gi.require_version.side_effect = ImportError() # When patching ...
Verify notification succeeds even if the `gi` package is not available.
test_plugin_dbus_gi_missing
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_gi_require_version_error(dbus_glib_environment): """ Verify notification succeeds even if `gi.require_version()` croaks. """ # Make `require_version` function raise a ValueError. gi = importlib.import_module("gi") gi.require_version.side_effect = ValueError("Something faile...
Verify notification succeeds even if `gi.require_version()` croaks.
test_plugin_dbus_gi_require_version_error
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_module_croaks(mocker, dbus_glib_environment): """ Verify plugin is not available when `dbus` module is missing. """ # Make importing `dbus` raise an ImportError. mocker.patch.dict( sys.modules, {'dbus': compile('raise ImportError()', 'dbus', 'exec')}) # When patchi...
Verify plugin is not available when `dbus` module is missing.
test_plugin_dbus_module_croaks
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_session_croaks(mocker, dbus_glib_environment): """ Verify notification fails if DBus croaks. """ mocker.patch('dbus.SessionBus', side_effect=DBusException('test')) setup_glib_environment() obj = apprise.Apprise.instantiate('dbus://', suppress_exceptions=False) # Emula...
Verify notification fails if DBus croaks.
test_plugin_dbus_session_croaks
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_dbus_interface_notify_croaks(mocker): """ Fail gracefully if underlying object croaks for whatever reason. """ # Inject an error when invoking `dbus.Interface().Notify()`. mocker.patch('dbus.SessionBus', spec=True) mocker.patch('dbus.Interface', spec=True, Notif...
Fail gracefully if underlying object croaks for whatever reason.
test_plugin_dbus_interface_notify_croaks
python
caronc/apprise
test/test_plugin_dbus.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_dbus.py
BSD-2-Clause
def test_plugin_email_smtplib_init_fail(mock_smtplib): """ NotifyEmail() Test exception handling when calling smtplib.SMTP() """ obj = Apprise.instantiate( 'mailto://user:pass@gmail.com', suppress_exceptions=False) assert isinstance(obj, email.NotifyEmail) # Support Exception handling...
NotifyEmail() Test exception handling when calling smtplib.SMTP()
test_plugin_email_smtplib_init_fail
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_url_escaping(): """ NotifyEmail() Test that user/passwords are properly escaped from URL """ # quote(' %20') passwd = '%20%2520' # Basically we want to check that ' ' equates to %20 and % equates to %25 # So the above translates to ' %20' (a space in front of %20). W...
NotifyEmail() Test that user/passwords are properly escaped from URL
test_plugin_email_url_escaping
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_url_variations(): """ NotifyEmail() Test URL variations to ensure parsing is correct """ # Test variations of username required to be an email address # user@example.com obj = Apprise.instantiate( 'mailto://{user}:{passwd}@example.com?smtp=example.com'.format( ...
NotifyEmail() Test URL variations to ensure parsing is correct
test_plugin_email_url_variations
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_dict_variations(): """ NotifyEmail() Test email dictionary variations to ensure parsing is correct """ # Test variations of username required to be an email address # user@example.com obj = Apprise.instantiate({ 'schema': 'mailto', 'user': 'apprise@example....
NotifyEmail() Test email dictionary variations to ensure parsing is correct
test_plugin_email_dict_variations
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl): """ NotifyEmail() support + in To Email address """ response = mock.Mock() mock_smtp_ssl.return_value = response mock_smtp.return_value = response # We want to test the case where a + is found in the To address; we want to ...
NotifyEmail() support + in To Email address
test_plugin_email_plus_in_toemail
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_formatting_990(mock_smtp, mock_smtp_ssl): """ NotifyEmail() GitHub Issue 990 https://github.com/caronc/apprise/issues/990 Email formatting not working correctly """ response = mock.Mock() mock_smtp_ssl.return_value = response mock_smtp.return_value = response ...
NotifyEmail() GitHub Issue 990 https://github.com/caronc/apprise/issues/990 Email formatting not working correctly
test_plugin_email_formatting_990
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_variables_1087(): """ NotifyEmail() GitHub Issue 1087 https://github.com/caronc/apprise/issues/1087 Email variables reported not working correctly """ # Valid Configuration result, _ = ConfigBase.config_parse(cleandoc(""" # # Test Email Parsing # urls:...
NotifyEmail() GitHub Issue 1087 https://github.com/caronc/apprise/issues/1087 Email variables reported not working correctly
test_plugin_email_variables_1087
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_host_detection_from_source_email(mock_smtp, mock_smtp_ssl): """ NotifyEmail() Discord Issue reporting that the following did not work: mailtos://?smtp=mobile.charter.net&pass=password&user=name@spectrum.net """ response = mock.Mock() mock_smtp_ssl.return_value = response m...
NotifyEmail() Discord Issue reporting that the following did not work: mailtos://?smtp=mobile.charter.net&pass=password&user=name@spectrum.net
test_plugin_host_detection_from_source_email
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_email_by_ipaddr_1113(mock_smtp, mock_smtp_ssl): """ NotifyEmail() GitHub Issue 1113 https://github.com/caronc/apprise/issues/1113 Email with ip addresses not working """ response = mock.Mock() mock_smtp_ssl.return_value = response mock_smtp.return_value = response ...
NotifyEmail() GitHub Issue 1113 https://github.com/caronc/apprise/issues/1113 Email with ip addresses not working
test_plugin_email_by_ipaddr_1113
python
caronc/apprise
test/test_plugin_email.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_email.py
BSD-2-Clause
def test_plugin_fcm_legacy_no_colors(mock_post_legacy): """ NotifyFCM() Legacy/APIKey `color=no` checks. """ obj = Apprise.instantiate( 'fcm://abc123/device/?color=no') assert mock_post_legacy.call_count == 0 # Send our notification assert obj.notify(title="title", body="body") is ...
NotifyFCM() Legacy/APIKey `color=no` checks.
test_plugin_fcm_legacy_no_colors
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_oauth_default(mock_post): """ NotifyFCM() general OAuth checks - success. Test using a valid Project ID and key file. """ obj = Apprise.instantiate( f'fcm://mock-project-id/device/#topic/?keyfile={FCM_KEYFILE}') # send our notification assert obj.notify("test") ...
NotifyFCM() general OAuth checks - success. Test using a valid Project ID and key file.
test_plugin_fcm_oauth_default
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_oauth_invalid_project_id(mock_post): """ NotifyFCM() OAuth checks, with invalid project id. """ # Test having a valid keyfile, but not a valid project id match. obj = Apprise.instantiate( f'fcm://invalid_project_id/device/?keyfile={FCM_KEYFILE}') # we'll fail as a r...
NotifyFCM() OAuth checks, with invalid project id.
test_plugin_fcm_oauth_invalid_project_id
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_oauth_keyfile_error(mock_post): """ NotifyFCM() OAuth checks, while unable to read key file. """ # Now we test using a valid Project ID but we can't open our file obj = Apprise.instantiate( f'fcm://mock-project-id/device/?keyfile={FCM_KEYFILE}') with mock.patch('bui...
NotifyFCM() OAuth checks, while unable to read key file.
test_plugin_fcm_oauth_keyfile_error
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_oauth_data_parameters(mock_post): """ NotifyFCM() OAuth checks, success. Test using a valid Project ID and data parameters. """ obj = Apprise.instantiate( f'fcm://mock-project-id/device/#topic/?keyfile={FCM_KEYFILE}' '&+key=value&+key2=value2' '&image_url...
NotifyFCM() OAuth checks, success. Test using a valid Project ID and data parameters.
test_plugin_fcm_oauth_data_parameters
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_oauth_no_colors(mock_post): """ Verify `color=no` work as intended. """ obj = Apprise.instantiate( f'fcm://mock-project-id/device/?keyfile={FCM_KEYFILE}' '&color=no') assert mock_post.call_count == 0 # Send our notification assert obj.notify(title="title...
Verify `color=no` work as intended.
test_plugin_fcm_oauth_no_colors
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_keyfile_parse_user_agent(mock_post): """ Test case with `user-agent` override. """ oauth = GoogleOAuth(user_agent="test-agent-override") assert oauth.load(FCM_KEYFILE) is True assert oauth.access_token is not None assert mock_post.call_count == 1 assert mock_post.cal...
Test case with `user-agent` override.
test_plugin_fcm_keyfile_parse_user_agent
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_keyfile_parse_keyfile_failures(mock_post: mock.Mock): """ Test some errors that can get thrown when trying to handle the `service_account.json` file. """ # Now we test a case where we can't access the file we've been pointed to: oauth = GoogleOAuth() with mock.patch('bui...
Test some errors that can get thrown when trying to handle the `service_account.json` file.
test_plugin_fcm_keyfile_parse_keyfile_failures
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_keyfile_parse_token_failures(mock_post): """ Test some web errors that can occur when speaking upstream with Google to get our token generated. """ mock_post.return_value.status_code = requests.codes.internal_server_error oauth = GoogleOAuth() assert oauth.load(FCM_KEYF...
Test some web errors that can occur when speaking upstream with Google to get our token generated.
test_plugin_fcm_keyfile_parse_token_failures
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def test_plugin_fcm_bad_keyfile_parse(): """ NotifyFCM() KeyFile Bad Service Account Type Tests """ path = os.path.join(PRIVATE_KEYFILE_DIR, 'service_account-bad-type.json') oauth = GoogleOAuth() assert oauth.load(path) is False
NotifyFCM() KeyFile Bad Service Account Type Tests
test_plugin_fcm_bad_keyfile_parse
python
caronc/apprise
test/test_plugin_fcm.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_fcm.py
BSD-2-Clause
def obj(glib_environment): """ Fixture to provide a mocked Apprise instance. """ # Create our instance obj = apprise.Apprise.instantiate('gnome://', suppress_exceptions=False) assert obj is not None assert isinstance(obj, NotifyGnome) is True # Set our duration to 0 to speed up timeout...
Fixture to provide a mocked Apprise instance.
obj
python
caronc/apprise
test/test_plugin_gnome.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_gnome.py
BSD-2-Clause
def test_plugin_gnome_image_success(glib_environment): """ Verify using the `image` query argument works as intended. """ obj = apprise.Apprise.instantiate( 'gnome://_/?image=True', suppress_exceptions=False) assert isinstance(obj, NotifyGnome) is True assert obj.notify(title='title', b...
Verify using the `image` query argument works as intended.
test_plugin_gnome_image_success
python
caronc/apprise
test/test_plugin_gnome.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_gnome.py
BSD-2-Clause
def test_plugin_gnome_priority(glib_environment): """ Verify correctness of the `priority` query argument. """ # Test Priority (alias of urgency) obj = apprise.Apprise.instantiate( 'gnome://_/?priority=invalid', suppress_exceptions=False) assert isinstance(obj, NotifyGnome) is True ...
Verify correctness of the `priority` query argument.
test_plugin_gnome_priority
python
caronc/apprise
test/test_plugin_gnome.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_gnome.py
BSD-2-Clause
def test_plugin_gnome_urgency(glib_environment): """ Verify correctness of the `urgency` query argument. """ # Test Urgeny obj = apprise.Apprise.instantiate( 'gnome://_/?urgency=invalid', suppress_exceptions=False) assert obj.urgency == 1 assert isinstance(obj, NotifyGnome) is True ...
Verify correctness of the `urgency` query argument.
test_plugin_gnome_urgency
python
caronc/apprise
test/test_plugin_gnome.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_gnome.py
BSD-2-Clause
def test_plugin_gnome_gi_croaks(): """ Verify notification fails when `gi.require_version()` croaks. """ # Make `require_version` function raise an error. try: gi = importlib.import_module("gi") except ModuleNotFoundError: raise pytest.skip("`gi` package not installed") gi.r...
Verify notification fails when `gi.require_version()` croaks.
test_plugin_gnome_gi_croaks
python
caronc/apprise
test/test_plugin_gnome.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_gnome.py
BSD-2-Clause
def terminal_notifier(mocker, tmp_path): """ Fixture for providing a surrogate for the `terminal-notifier` program. """ notifier_program = tmp_path.joinpath("terminal-notifier") notifier_program.write_text('#!/bin/sh\n\necho hello') # Set execute bit. os.chmod(notifier_program, 0o755) ...
Fixture for providing a surrogate for the `terminal-notifier` program.
terminal_notifier
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def test_plugin_macosx_terminal_notifier_not_executable( pretend_macos, terminal_notifier): """ When the `terminal-notifier` program is inaccessible or not executable, we are unable to send notifications. """ obj = apprise.Apprise.instantiate('macosx://', suppress_exceptions=False) # U...
When the `terminal-notifier` program is inaccessible or not executable, we are unable to send notifications.
test_plugin_macosx_terminal_notifier_not_executable
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def test_plugin_macosx_terminal_notifier_invalid(macos_notify_environment): """ When the `terminal-notifier` program is wrongly addressed, notifications should fail. """ obj = apprise.Apprise.instantiate('macosx://', suppress_exceptions=False) # Let's disrupt the path location. obj.notify_...
When the `terminal-notifier` program is wrongly addressed, notifications should fail.
test_plugin_macosx_terminal_notifier_invalid
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def test_plugin_macosx_terminal_notifier_croaks( mocker, macos_notify_environment): """ When the `terminal-notifier` program croaks on execution, notifications should fail. """ # Emulate a failing program. mocker.patch("subprocess.Popen", return_value=Mock(returncode=1)) obj = appr...
When the `terminal-notifier` program croaks on execution, notifications should fail.
test_plugin_macosx_terminal_notifier_croaks
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def test_plugin_macosx_pretend_linux(mocker, pretend_macos): """ The notification object is disabled when pretending to run on Linux. """ # When patching something which has a side effect on the module-level code # of a plugin, make sure to reload it. mocker.patch("platform.system", return_valu...
The notification object is disabled when pretending to run on Linux.
test_plugin_macosx_pretend_linux
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def test_plugin_macosx_pretend_old_macos(mocker, macos_version): """ The notification object is disabled when pretending to run on older macOS. """ # When patching something which has a side effect on the module-level code # of a plugin, make sure to reload it. mocker.patch("platform.mac_ver", ...
The notification object is disabled when pretending to run on older macOS.
test_plugin_macosx_pretend_old_macos
python
caronc/apprise
test/test_plugin_macosx.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_macosx.py
BSD-2-Clause
def mock_function_handing(url, data, **kwargs): """ dummy function for handling image posts (as a failure) """ response_obj = { 'room_id': '!abc123:localhost', 'room_alias': '#abc123:localhost', 'joined_rooms': ['!abc123:localhost', '!def456:localhost'...
dummy function for handling image posts (as a failure)
mock_function_handing
python
caronc/apprise
test/test_plugin_matrix.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_matrix.py
BSD-2-Clause
def mock_function_handing(url, data, **kwargs): """ dummy function for handling image posts (successfully) """ response_obj = { 'room_id': '!abc123:localhost', 'room_alias': '#abc123:localhost', 'joined_rooms': ['!abc123:localhost', '!def456:localhost'...
dummy function for handling image posts (successfully)
mock_function_handing
python
caronc/apprise
test/test_plugin_matrix.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_matrix.py
BSD-2-Clause
def mqtt_client_mock(mocker): """ Mocks an MQTT client and response and returns the mocked client. """ if "paho" not in sys.modules: raise pytest.skip("Requires that `paho-mqtt` is installed") # Establish mock of the `publish()` response object. publish_result = Mock(**{ "rc": ...
Mocks an MQTT client and response and returns the mocked client.
mqtt_client_mock
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_paho_import_error(): """ Verify `NotifyMQTT` is disabled when `paho.mqtt.client` fails loading. """ # without the library, the object can't be instantiated obj = apprise.Apprise.instantiate( 'mqtt://user:pass@localhost/my/topic') assert obj is None
Verify `NotifyMQTT` is disabled when `paho.mqtt.client` fails loading.
test_plugin_mqtt_paho_import_error
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_default_success(mqtt_client_mock): """ Verify `NotifyMQTT` succeeds and has appropriate default settings. """ # Instantiate the notifier. obj = apprise.Apprise.instantiate( 'mqtt://localhost:1234/my/topic', suppress_exceptions=False) assert isinstance(obj, NotifyMQT...
Verify `NotifyMQTT` succeeds and has appropriate default settings.
test_plugin_mqtt_default_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_multiple_topics_success(mqtt_client_mock): """ Verify submission to multiple MQTT topics. """ # Designate multiple topic targets. obj = apprise.Apprise.instantiate( 'mqtt://localhost/my/topic,my/other/topic', suppress_exceptions=False) # Verify we have load...
Verify submission to multiple MQTT topics.
test_plugin_mqtt_multiple_topics_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_to_success(mqtt_client_mock): """ Verify `NotifyMQTT` succeeds with the `to=` parameter. """ # Leverage the `to=` argument to identify the topic. obj = apprise.Apprise.instantiate( 'mqtt://localhost?to=my/topic', suppress_exceptions=False) assert isinstance(obj, Not...
Verify `NotifyMQTT` succeeds with the `to=` parameter.
test_plugin_mqtt_to_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_valid_settings_success(mqtt_client_mock): """ Verify settings as URL parameters will be accepted. """ # Instantiate the notifier. obj = apprise.Apprise.instantiate( 'mqtt://localhost/my/topic?qos=1&version=v3.1', suppress_exceptions=False) assert isinstance...
Verify settings as URL parameters will be accepted.
test_plugin_mqtt_valid_settings_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_invalid_settings_failure(mqtt_client_mock): """ Verify notifier instantiation croaks on invalid settings. """ # Test case for invalid/unsupported MQTT version. with pytest.raises(TypeError): apprise.Apprise.instantiate( 'mqtt://localhost?version=v1.0.0.0', s...
Verify notifier instantiation croaks on invalid settings.
test_plugin_mqtt_invalid_settings_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_bad_url_failure(mqtt_client_mock): """ Verify notifier is disabled when using an invalid URL. """ obj = apprise.Apprise.instantiate('mqtt://', suppress_exceptions=False) assert obj is None
Verify notifier is disabled when using an invalid URL.
test_plugin_mqtt_bad_url_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_no_topic_failure(mqtt_client_mock): """ Verify notification fails when no topic is given. """ obj = apprise.Apprise.instantiate( 'mqtt://localhost', suppress_exceptions=False) assert isinstance(obj, NotifyMQTT) assert obj.notify(body="test=test") is False
Verify notification fails when no topic is given.
test_plugin_mqtt_no_topic_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_tls_no_certificates_failure(mqtt_client_mock, mocker): """ Verify TLS does not work without access to CA root certificates. """ # Clear CA certificates. mocker.patch.object(NotifyMQTT, "CA_CERTIFICATE_FILE_LOCATIONS", []) obj = apprise.Apprise.instantiate( 'mqtts:/...
Verify TLS does not work without access to CA root certificates.
test_plugin_mqtt_tls_no_certificates_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_tls_no_verify_success(mqtt_client_mock): """ Verify TLS encrypted connections work with `verify=False`. """ # A single user (not password) + no verifying of host obj = apprise.Apprise.instantiate( 'mqtts://user:pass@localhost/my/topic?verify=False', suppress_exc...
Verify TLS encrypted connections work with `verify=False`.
test_plugin_mqtt_tls_no_verify_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_session_client_id_success(mqtt_client_mock): """ Verify handling `session=yes` and `client_id=` works. """ obj = apprise.Apprise.instantiate( 'mqtt://user@localhost/my/topic?session=yes&client_id=apprise', suppress_exceptions=False) assert isinstance(obj, Notif...
Verify handling `session=yes` and `client_id=` works.
test_plugin_mqtt_session_client_id_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_retain(mqtt_client_mock): """ Verify handling of Retain Message Flag """ obj = apprise.Apprise.instantiate( 'mqtt://user@localhost/my/topic?retain=yes', suppress_exceptions=False) assert isinstance(obj, NotifyMQTT) assert obj.url().startswith('mqtt://user@l...
Verify handling of Retain Message Flag
test_plugin_mqtt_retain
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_connect_failure(mqtt_client_mock): """ Verify `NotifyMQTT` fails when MQTT `connect()` fails. """ # Emulate a situation where the `connect()` method fails. mqtt_client_mock.connect.return_value = 2 obj = apprise.Apprise.instantiate( 'mqtt://localhost/my/topic', sup...
Verify `NotifyMQTT` fails when MQTT `connect()` fails.
test_plugin_mqtt_connect_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_reconnect_failure(mqtt_client_mock): """ Verify `NotifyMQTT` fails when MQTT `reconnect()` fails. """ # Emulate a situation where MQTT reconnect fails. mqtt_client_mock.reconnect.return_value = 2 mqtt_client_mock.is_connected.return_value = False obj = apprise.Apprise....
Verify `NotifyMQTT` fails when MQTT `reconnect()` fails.
test_plugin_mqtt_reconnect_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_publish_failure(mqtt_client_mock): """ Verify `NotifyMQTT` fails when MQTT `publish()` fails. """ # Emulate a situation where the `publish()` method fails. mqtt_response = mqtt_client_mock.publish.return_value mqtt_response.rc = 2 obj = apprise.Apprise.instantiate( ...
Verify `NotifyMQTT` fails when MQTT `publish()` fails.
test_plugin_mqtt_publish_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_exception_failure(mqtt_client_mock): """ Verify `NotifyMQTT` fails when an exception happens. """ obj = apprise.Apprise.instantiate( 'mqtt://localhost/my/topic', suppress_exceptions=False) # Emulate a situation where `connect()` raises an exception. mqtt_client_moc...
Verify `NotifyMQTT` fails when an exception happens.
test_plugin_mqtt_exception_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_not_published_failure(mqtt_client_mock, mocker): """ Verify `NotifyMQTT` fails there if the message has not been published. """ # Speed up testing by making `NotifyMQTT` not block anywhere. mocker.patch.object(NotifyMQTT, "socket_read_timeout", 0.00025) mocker.patch.object(...
Verify `NotifyMQTT` fails there if the message has not been published.
test_plugin_mqtt_not_published_failure
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_mqtt_not_published_recovery_success(mqtt_client_mock): """ Verify `NotifyMQTT` success after recovering from is_published==False. """ # Emulate a situation where `is_published()` returns `False`. mqtt_response = mqtt_client_mock.publish.return_value mqtt_response.is_published.re...
Verify `NotifyMQTT` success after recovering from is_published==False.
test_plugin_mqtt_not_published_recovery_success
python
caronc/apprise
test/test_plugin_mqtt.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_mqtt.py
BSD-2-Clause
def test_plugin_msteams_templating_basic_success( request_mock, msteams_url, tmpdir): """ NotifyMSTeams() Templating - success. Test cases where URL and JSON is valid. """ template = tmpdir.join("simple.json") template.write(""" { "@type": "MessageCard", "@context": "htt...
NotifyMSTeams() Templating - success. Test cases where URL and JSON is valid.
test_plugin_msteams_templating_basic_success
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_plugin_msteams_templating_json_missing_type( request_mock, msteams_url, tmpdir): """ NotifyMSTeams() Templating - invalid JSON. Test case where we're missing the @type part of the URL. """ template = tmpdir.join("missing_type.json") template.write(""" { "@context": "h...
NotifyMSTeams() Templating - invalid JSON. Test case where we're missing the @type part of the URL.
test_plugin_msteams_templating_json_missing_type
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_plugin_msteams_templating_json_missing_context( request_mock, msteams_url, tmpdir): """ NotifyMSTeams() Templating - invalid JSON. Test cases where we're missing the @context part of the URL. """ template = tmpdir.join("missing_context.json") template.write(""" { "@ty...
NotifyMSTeams() Templating - invalid JSON. Test cases where we're missing the @context part of the URL.
test_plugin_msteams_templating_json_missing_context
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_plugin_msteams_templating_load_json_failure( request_mock, msteams_url, tmpdir): """ NotifyMSTeams() Templating - template loading failure. Test a case where we can not access the file. """ template = tmpdir.join("empty.json") template.write("") obj = Apprise.instantiate('...
NotifyMSTeams() Templating - template loading failure. Test a case where we can not access the file.
test_plugin_msteams_templating_load_json_failure
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_plugin_msteams_templating_target_success( request_mock, msteams_url, tmpdir): """ NotifyMSTeams() Templating - success with target. A more complicated example; uses a target. """ template = tmpdir.join("more_complicated_example.json") template.write(""" { "@type": "Me...
NotifyMSTeams() Templating - success with target. A more complicated example; uses a target.
test_plugin_msteams_templating_target_success
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_invalid_template_filename( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries - invalid template filename. """ config = tmpdir.join("msteams01.yml") config.write(""" urls: - {url}: - tag: 'msteam...
NotifyMSTeams() YAML Configuration Entries - invalid template filename.
test_msteams_yaml_config_invalid_template_filename
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_token_identifiers( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries - test token identifiers. """ config = tmpdir.join("msteams01.yml") config.write(""" urls: - {url}: - tag: 'msteams' ...
NotifyMSTeams() YAML Configuration Entries - test token identifiers.
test_msteams_yaml_config_token_identifiers
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_no_bullet_under_url_1( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries - no bullet 1. Now again but without a bullet under the url definition. """ config = tmpdir.join("msteams02.yml") config.write(""" ...
NotifyMSTeams() YAML Configuration Entries - no bullet 1. Now again but without a bullet under the url definition.
test_msteams_yaml_config_no_bullet_under_url_1
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_dictionary_file( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries. Try again but store the content as a dictionary in the configuration file. """ config = tmpdir.join("msteams03.yml") config.write(""" ur...
NotifyMSTeams() YAML Configuration Entries. Try again but store the content as a dictionary in the configuration file.
test_msteams_yaml_config_dictionary_file
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_no_bullet_under_url_2( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries - no bullet 2. Now again but without a bullet under the url definition. """ config = tmpdir.join("msteams04.yml") config.write(""" ...
NotifyMSTeams() YAML Configuration Entries - no bullet 2. Now again but without a bullet under the url definition.
test_msteams_yaml_config_no_bullet_under_url_2
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_combined( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries. Now let's do a combination of the two. """ config = tmpdir.join("msteams05.yml") config.write(""" urls: - {url}: - tag: 'msteams'...
NotifyMSTeams() YAML Configuration Entries. Now let's do a combination of the two.
test_msteams_yaml_config_combined
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_msteams_yaml_config_token_mismatch( request_mock, msteams_url, simple_template, tmpdir): """ NotifyMSTeams() YAML Configuration Entries. Now let's do a test where our tokens is not the expected dictionary we want to see. """ config = tmpdir.join("msteams06.yml") config.writ...
NotifyMSTeams() YAML Configuration Entries. Now let's do a test where our tokens is not the expected dictionary we want to see.
test_msteams_yaml_config_token_mismatch
python
caronc/apprise
test/test_plugin_msteams.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_msteams.py
BSD-2-Clause
def test_plugin_ntfy_message_to_attach(mock_post): """ NotifyNtfy() large messages converted into attachments """ # Prepare Mock return object response = mock.Mock() response.content = GOOD_RESPONSE_TEXT response.status_code = requests.codes.ok mock_post.return_value = response # ...
NotifyNtfy() large messages converted into attachments
test_plugin_ntfy_message_to_attach
python
caronc/apprise
test/test_plugin_ntfy.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_ntfy.py
BSD-2-Clause
def test_plugin_slack_multiple_thread_reply(mock_request): """ NotifySlack() Send Notification to multiple channels as Reply """ # Generate a (valid) bot token token = 'xoxb-1234-1234-abc124' thread_id_1, thread_id_2 = 100, 200 request = mock.Mock() request.content = dumps({ 'o...
NotifySlack() Send Notification to multiple channels as Reply
test_plugin_slack_multiple_thread_reply
python
caronc/apprise
test/test_plugin_slack.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_slack.py
BSD-2-Clause
def post(url, data, **kwargs): """ Since Publishing a token requires 2 posts, we need to return our response depending on what step we're on """ # A request robj = mock.Mock() robj.text = '' robj.status_code = requests.codes.ok if data.find('=Cre...
Since Publishing a token requires 2 posts, we need to return our response depending on what step we're on
post
python
caronc/apprise
test/test_plugin_sns.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_sns.py
BSD-2-Clause
def test_plugin_twilio_auth(mock_post): """ NotifyTwilio() Auth - account-wide auth token - API key and its own auth token """ response = mock.Mock() response.content = '' response.status_code = requests.codes.ok # Prepare Mock mock_post.return_value = response # Init...
NotifyTwilio() Auth - account-wide auth token - API key and its own auth token
test_plugin_twilio_auth
python
caronc/apprise
test/test_plugin_twilio.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twilio.py
BSD-2-Clause
def _can_not_send_response(url, *args, **kwargs): """ Simulate a case where we can't send a notification """ # Force a failure request = mock.Mock() request.status_code = 403 request.content = '{}' return request
Simulate a case where we can't send a notification
_can_not_send_response
python
caronc/apprise
test/test_plugin_twist.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twist.py
BSD-2-Clause
def test_plugin_twist_fetch(mock_post, mock_get): """ NotifyTwist() fetch() fetch() is a wrapper that handles all kinds of edge cases and even attempts to re-authenticate to the Twist server if our token happens to expire. This tests these edge cases """ # Track our iteration; by tracing...
NotifyTwist() fetch() fetch() is a wrapper that handles all kinds of edge cases and even attempts to re-authenticate to the Twist server if our token happens to expire. This tests these edge cases
test_plugin_twist_fetch
python
caronc/apprise
test/test_plugin_twist.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twist.py
BSD-2-Clause
def _reauth_response(url, *args, **kwargs): """ Tests re-authentication process and then a successful retry """ # Default configuration request = mock.Mock() request.status_code = requests.codes.ok # Simulate a successful login request.content = ...
Tests re-authentication process and then a successful retry
_reauth_response
python
caronc/apprise
test/test_plugin_twist.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twist.py
BSD-2-Clause
def _reauth_exception_response(url, *args, **kwargs): """ Tests exception thrown after re-authentication process """ # Default configuration request = mock.Mock() request.status_code = requests.codes.ok # Simulate a successful login request.content = dum...
Tests exception thrown after re-authentication process
_reauth_exception_response
python
caronc/apprise
test/test_plugin_twist.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twist.py
BSD-2-Clause
def _reauth_failed_response(url, *args, **kwargs): """ Tests re-authentication process and have it not succeed """ # Default configuration request = mock.Mock() request.status_code = requests.codes.ok # Simulate a successful login request.content = dumps...
Tests re-authentication process and have it not succeed
_reauth_failed_response
python
caronc/apprise
test/test_plugin_twist.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twist.py
BSD-2-Clause
def ensure_get_verify_credentials_is_mocked(mocker, good_message_response): """ Make sure requests to https://api.twitter.com/1.1/account/verify_credentials.json do not escape the test harness, for all test case functions. """ # noqa:E501 mock_get = mocker.patch("requests.get") mock_get.return_...
Make sure requests to https://api.twitter.com/1.1/account/verify_credentials.json do not escape the test harness, for all test case functions.
ensure_get_verify_credentials_is_mocked
python
caronc/apprise
test/test_plugin_twitter.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twitter.py
BSD-2-Clause
def test_plugin_twitter_dm_caching( mocker, twitter_url, good_message_response, good_media_response): """ Verify that the `NotifyTwitter.{_user_cache,_whoami_cache}` caches work as intended. """ # This is the request to `account/verify_credentials.json`. # Explicitly mock it her...
Verify that the `NotifyTwitter.{_user_cache,_whoami_cache}` caches work as intended.
test_plugin_twitter_dm_caching
python
caronc/apprise
test/test_plugin_twitter.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twitter.py
BSD-2-Clause
def test_plugin_twitter_dm_attachments_message_fails( mocker, twitter_url, good_media_response, bad_message_response): """ Test case with a bad media response. """ mock_post = mocker.patch("requests.post") mock_post.side_effect = [good_media_response, bad_message_response] # Cr...
Test case with a bad media response.
test_plugin_twitter_dm_attachments_message_fails
python
caronc/apprise
test/test_plugin_twitter.py
https://github.com/caronc/apprise/blob/master/test/test_plugin_twitter.py
BSD-2-Clause