RHEL9 Support - Test cases to leverage unittest.mock when possible (#658)

This commit is contained in:
Chris Caron 2022-08-31 20:05:40 -04:00 committed by GitHub
parent 782f2e602b
commit 2d5ab59252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 557 additions and 69 deletions

View File

@ -1,6 +1,6 @@
coverage
flake8
mock
mock; python_version=='2.7'
pytest
pytest-cov
tox

View File

@ -60,7 +60,7 @@ Techulus Push, Telegram, Twilio, Twitter, Twist, XBMC, Vonage, Webex Teams}
Name: python-%{pypi_name}
Version: 1.0.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A simple wrapper to many popular notification services used today
License: MIT
URL: https://github.com/caronc/%{pypi_name}
@ -161,7 +161,12 @@ Requires: python%{python3_pkgversion}-cryptography
Requires: python%{python3_pkgversion}-yaml
%if %{with tests}
%if 0%{?rhel} >= 9
# Do not import python3-mock
%else
# python-mock switched to unittest.mock
BuildRequires: python%{python3_pkgversion}-mock
%endif
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pytest-runner
%endif
@ -183,6 +188,17 @@ rm -f apprise/py3compat/asyncio.py
%patch1 -p1
%endif
%if 0%{?rhel} >= 9
# Nothing to do under normal circumstances; this line here allows legacy
# copies of Apprise to still build against this one
find test -type f -name '*.py' -exec \
sed -i -e 's|^import mock|from unittest import mock|g' {} \;
%else
# support python-mock (remain backwards compatible with older distributions)
find test -type f -name '*.py' -exec \
sed -i -e 's|^from unittest import mock|import mock|g' {} \;
%endif
%build
%if 0%{?with_python2}
%py2_build
@ -243,6 +259,9 @@ LANG=C.UTF-8 PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version
%endif
%changelog
* Wed Aug 31 2022 Chris Caron <lead2gold@gmail.com> - 1.0.0-2
- Rebuilt for RHEL9 Support
* Sat Aug 6 2022 Chris Caron <lead2gold@gmail.com> - 1.0.0-1
- Updated to v1.0.0

View File

@ -26,7 +26,14 @@ import re
import os
import six
import requests
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from json import dumps
from random import choice
from string import ascii_uppercase as str_alpha

View File

@ -29,7 +29,14 @@ import sys
import six
import pytest
import requests
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from os.path import dirname
from os.path import join

View File

@ -26,7 +26,14 @@
import sys
import six
import io
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
from apprise import NotifyFormat
from apprise import ConfigFormat

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
from apprise.attachment.AttachBase import AttachBase

View File

@ -25,7 +25,14 @@
import re
import time
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from os.path import dirname
from os.path import join
from apprise.attachment.AttachBase import AttachBase

View File

@ -25,7 +25,14 @@
import re
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
import mimetypes
from os.path import join

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
from __future__ import print_function
import re
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
import json
from inspect import cleandoc

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from apprise.config.ConfigFile import ConfigFile
from apprise.plugins.NotifyBase import NotifyBase
from apprise.AppriseAsset import AppriseAsset

View File

@ -26,7 +26,14 @@
import six
import time
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise.common import ConfigFormat
from apprise.config.ConfigHTTP import ConfigHTTP

View File

@ -25,7 +25,14 @@
import os
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from apprise import Apprise

View File

@ -27,7 +27,14 @@ import sys
from json import loads
import pytest
import requests
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import apprise

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import ctypes
from apprise import AppriseLocale

View File

@ -26,7 +26,14 @@
import re
import os
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import Apprise

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from helpers import AppriseURLTester
from apprise import plugins
from apprise import NotifyType

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from helpers import AppriseURLTester

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import json
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from helpers import AppriseURLTester

View File

@ -25,7 +25,14 @@
import os
import sys
import re
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from apprise import Apprise

View File

@ -25,7 +25,14 @@
# Disable logging for a cleaner testing output
import logging
import requests
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import apprise
from apprise.plugins.NotifyDapnet import DapnetPriority

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from helpers import AppriseURLTester

View File

@ -26,7 +26,14 @@
import os
import re
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import smtplib
from email.header import decode_header

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from json import dumps
from apprise import Apprise
from apprise import plugins

View File

@ -33,7 +33,14 @@ import io
import os
import six
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
import json

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -25,7 +25,14 @@
import six
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from helpers import AppriseURLTester
from apprise import plugins

View File

@ -26,7 +26,14 @@
import re
import six
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import sys
import types
import apprise

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import sys
import types
import pytest

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
import apprise

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import six
import pytest
import apprise

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from helpers import AppriseURLTester

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from apprise import Apprise

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from apprise import NotifyType

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
import apprise

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from helpers import module_reload
import apprise

View File

@ -25,7 +25,14 @@
import os
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from helpers import AppriseURLTester
from apprise import plugins

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
import pytest
from apprise import plugins

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import re
import sys
import ssl

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import json
import requests
import pytest

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from helpers import AppriseURLTester

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from helpers import AppriseURLTester

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import json
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
import apprise

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from datetime import datetime

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise.plugins.NotifyOpsgenie import OpsgeniePriority
import apprise

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise.plugins.NotifyProwl import ProwlPriority

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from json import dumps

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
import pytest
from json import dumps

View File

@ -25,7 +25,14 @@
import os
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from json import dumps
from apprise import AppriseAttachment

View File

@ -25,7 +25,14 @@
import six
import requests
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
from apprise import plugins
from helpers import AppriseURLTester

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import os
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import Apprise

View File

@ -25,7 +25,14 @@
import os
import sys
from json import loads
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
import json

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from json import dumps

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -25,7 +25,14 @@
import os
import sys
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from apprise import plugins
from apprise import Apprise

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from apprise import plugins

View File

@ -25,7 +25,14 @@
import os
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from json import dumps
from apprise import plugins

View File

@ -25,7 +25,14 @@
import re
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import apprise
import socket

View File

@ -27,7 +27,14 @@ import os
import six
import sys
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from json import dumps
from json import loads

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
import pytest
from json import dumps

View File

@ -23,7 +23,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import requests
from json import dumps
from apprise import plugins

View File

@ -25,7 +25,14 @@
import os
import six
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from json import dumps

View File

@ -22,7 +22,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import pytest
import requests
from json import dumps

View File

@ -24,7 +24,14 @@
# THE SOFTWARE.
import pytest
import mock
try:
# Python 3.x
from unittest import mock
except ImportError:
# Python 2.7
import mock
import sys
import six
import types