From eb85dca076eb1d8fea17446edbc57bc1e3667f39 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 20 Nov 2022 18:01:26 -0800 Subject: [PATCH] Improve module vs. class imports re. `NotifyBase` and friends (#771) --- apprise/plugins/__init__.py | 8 +------- test/test_plugin_email.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/apprise/plugins/__init__.py b/apprise/plugins/__init__.py index 88969cca..5c0b3532 100644 --- a/apprise/plugins/__init__.py +++ b/apprise/plugins/__init__.py @@ -31,10 +31,7 @@ from os.path import dirname from os.path import abspath # Used for testing -from . import NotifyEmail as NotifyEmailBase - -# NotifyBase object is passed in as a module not class -from . import NotifyBase +from .NotifyBase import NotifyBase from ..common import NotifyImageSize from ..common import NOTIFY_IMAGE_SIZES @@ -53,9 +50,6 @@ __all__ = [ 'NotifyImageSize', 'NOTIFY_IMAGE_SIZES', 'NotifyType', 'NOTIFY_TYPES', 'NotifyBase', - # NotifyEmail Base Module (used for NotifyEmail testing) - 'NotifyEmailBase', - # Tokenizer 'url_to_dict', ] diff --git a/test/test_plugin_email.py b/test/test_plugin_email.py index da6e6534..65f86ce0 100644 --- a/test/test_plugin_email.py +++ b/test/test_plugin_email.py @@ -23,6 +23,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +import logging import os import re from unittest import mock @@ -34,15 +35,13 @@ from apprise import NotifyType, NotifyBase from apprise import Apprise from apprise import AttachBase from apprise import AppriseAttachment -from apprise.plugins import NotifyEmailBase +from apprise.plugins.NotifyEmail import NotifyEmail +from apprise.plugins import NotifyEmail as NotifyEmailModule # Disable logging for a cleaner testing output -import logging - -from apprise.plugins.NotifyEmail import NotifyEmail - logging.disable(logging.CRITICAL) + # Attachment Directory TEST_VAR_DIR = os.path.join(os.path.dirname(__file__), 'var') @@ -420,7 +419,7 @@ def test_plugin_email_webbase_lookup(mock_smtp, mock_smtpssl): """ # Insert a test email at the head of our table - NotifyEmailBase.EMAIL_TEMPLATES = ( + NotifyEmailModule.EMAIL_TEMPLATES = ( ( # Testing URL 'Testing Lookup', @@ -429,10 +428,10 @@ def test_plugin_email_webbase_lookup(mock_smtp, mock_smtpssl): 'port': 123, 'smtp_host': 'smtp.l2g.com', 'secure': True, - 'login_type': (NotifyEmailBase.WebBaseLogin.USERID, ) + 'login_type': (NotifyEmailModule.WebBaseLogin.USERID, ) }, ), - ) + NotifyEmailBase.EMAIL_TEMPLATES + ) + NotifyEmailModule.EMAIL_TEMPLATES obj = Apprise.instantiate( 'mailto://user:pass@l2g.com', suppress_exceptions=True)