From 15e16ad53a8c4c4909e8eb2f527590b4fb82db8b Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sun, 10 Sep 2023 11:36:23 -0400 Subject: [PATCH] Custom XML Service improvements using params (#945) --- apprise/plugins/NotifyXML.py | 11 +++---- test/test_plugin_custom_xml.py | 58 ++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/apprise/plugins/NotifyXML.py b/apprise/plugins/NotifyXML.py index d1607e896b..9a8cd824da 100644 --- a/apprise/plugins/NotifyXML.py +++ b/apprise/plugins/NotifyXML.py @@ -216,9 +216,6 @@ def __init__(self, headers=None, method=None, payload=None, params=None, # Store our extra headers self.headers.update(headers) - # Set our xsd url - self.xsd_url = self.xsd_default_url.format(version=self.xsd_ver) - self.payload_overrides = {} self.payload_extras = {} if payload: @@ -240,11 +237,13 @@ def __init__(self, headers=None, method=None, payload=None, params=None, self.payload_map[key] = v self.payload_overrides[key] = v - # Over-ride XSD URL as data is no longer known - self.xsd_url = None - else: self.payload_extras[key] = v + + # Set our xsd url + self.xsd_url = None if self.payload_overrides or self.payload_extras \ + else self.xsd_default_url.format(version=self.xsd_ver) + return def url(self, privacy=False, *args, **kwargs): diff --git a/test/test_plugin_custom_xml.py b/test/test_plugin_custom_xml.py index 7568709886..1de55f4182 100644 --- a/test/test_plugin_custom_xml.py +++ b/test/test_plugin_custom_xml.py @@ -327,7 +327,7 @@ def test_plugin_custom_xml_edge_cases(mock_get, mock_post): assert isinstance(instance, NotifyXML) # XSD URL is disabled due to custom formatting - assert instance.xsd_url is not None + assert instance.xsd_url is None response = instance.send(title='title', body='body') assert response is True @@ -351,5 +351,57 @@ def test_plugin_custom_xml_edge_cases(mock_get, mock_post): assert re.search(r'title', details[1]['data']) # No over-ride assert re.search(r'body', details[1]['data']) - # since there is no over-ride, an xmlns:xsi is provided - assert re.search(r'[1-9]+\.[0-9]+', details[1]['data']) is None + + # Test our data set for our key/value pair + assert re.search(r'info', details[1]['data']) + + # Subject is swapped for Title + assert re.search(r'title', details[1]['data']) is None + assert re.search(r'title', details[1]['data']) + + # Message is swapped for Body + assert re.search(r'body', details[1]['data']) is None + assert re.search(r'body', details[1]['data'])