From e50828ebb13c2f9638464788d5a37e1f62bc2a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislav=20Ochotnick=C3=BD?= Date: Sun, 23 Feb 2025 16:26:18 +0100 Subject: [PATCH] Add a testcase for MM POST URL with default port Mattermost should not force port to appear in the post URL if not provided in Apprise URL. --- test/test_plugin_mattermost.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test_plugin_mattermost.py b/test/test_plugin_mattermost.py index 0fdf94e1..a048aba8 100644 --- a/test/test_plugin_mattermost.py +++ b/test/test_plugin_mattermost.py @@ -199,3 +199,27 @@ def test_plugin_mattermost_channels(request_mock): assert posted_json['username'] == 'user1' assert posted_json['channel'] == 'two' assert posted_json['text'] == 'title\r\nbody' + +def test_mattermost_post_default_port(request_mock): + # Test token + token = 'token' + + # Instantiate our URL + obj = Apprise.instantiate( + 'mmosts://mattermost.example.com/{token}'.format( + token=token) + ) + + assert isinstance(obj, NotifyMattermost) + assert obj.notify(body="body", title='title') is True + + # Make sure we don't use port if not provided + assert request_mock.called is True + assert request_mock.call_count == 1 + assert request_mock.call_args_list[0][0][0].startswith( + 'https://mattermost.example.com/hooks/token') + + # Our Posted JSON Object + posted_json = json.loads(request_mock.call_args_list[0][1]['data']) + assert 'text' in posted_json + assert posted_json['text'] == 'title\r\nbody'