mirror of https://github.com/caronc/apprise
test cases reworked for situations where smpplib is unavailable
parent
d40757c74f
commit
d7cb97406f
|
@ -99,8 +99,7 @@ apprise_url_tests = (
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
'smpplib' in sys.modules,
|
'smpplib' in sys.modules,
|
||||||
reason="Requires that smpplib NOT be installed")
|
reason="Requires that smpplib NOT be installed")
|
||||||
@mock.patch('smpplib.client.Client')
|
def test_plugin_smpplib_import_error():
|
||||||
def test_plugin_smpplib_import_error(mock_client):
|
|
||||||
"""
|
"""
|
||||||
NotifySMPP() smpplib loading failure
|
NotifySMPP() smpplib loading failure
|
||||||
"""
|
"""
|
||||||
|
@ -115,11 +114,20 @@ def test_plugin_smpplib_import_error(mock_client):
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
'smpplib' not in sys.modules, reason="Requires smpplib")
|
'smpplib' not in sys.modules, reason="Requires smpplib")
|
||||||
@mock.patch('smpplib.client.Client')
|
def test_plugin_smpp_urls():
|
||||||
def test_plugin_smpp_urls(mock_client):
|
|
||||||
"""
|
"""
|
||||||
NotifySMPP() Apprise URLs
|
NotifySMPP() Apprise URLs
|
||||||
"""
|
"""
|
||||||
|
# mock nested inside of outside function to avoid failing
|
||||||
|
# when smpplib is unavailable
|
||||||
|
with mock.patch('smpplib.client.Client') as mock_client_class:
|
||||||
|
mock_client_instance = mock.Mock()
|
||||||
|
mock_client_class.return_value = mock_client_instance
|
||||||
|
|
||||||
|
# Raise exception on connect
|
||||||
|
mock_client_instance.connect.return_value = True
|
||||||
|
mock_client_instance.bind_transmitter.return_value = True
|
||||||
|
mock_client_instance.send_message.return_value = True
|
||||||
|
|
||||||
# Run our general tests
|
# Run our general tests
|
||||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||||
|
@ -127,12 +135,14 @@ def test_plugin_smpp_urls(mock_client):
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
'smpplib' not in sys.modules, reason="Requires smpplib")
|
'smpplib' not in sys.modules, reason="Requires smpplib")
|
||||||
@mock.patch('smpplib.client.Client')
|
def test_plugin_smpp_edge_case():
|
||||||
def test_plugin_smpp_edge_case(mock_client_class):
|
|
||||||
"""
|
"""
|
||||||
NotifySMPP() Apprise Edge Case
|
NotifySMPP() Apprise Edge Case
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# mock nested inside of outside function to avoid failing
|
||||||
|
# when smpplib is unavailable
|
||||||
|
with mock.patch('smpplib.client.Client') as mock_client_class:
|
||||||
mock_client_instance = mock.Mock()
|
mock_client_instance = mock.Mock()
|
||||||
mock_client_class.return_value = mock_client_instance
|
mock_client_class.return_value = mock_client_instance
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue