Asset passed into AppriseConfig() is now recognized (#272)

This commit is contained in:
Chris Caron 2020-08-14 21:40:19 -04:00 committed by GitHub
parent e65b1dc5af
commit 4f4b15d47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -204,7 +204,8 @@ def main(body, title, config, attach, urls, notification_type, theme, tag,
# identified on the command line
a.add(AppriseConfig(
paths=[f for f in DEFAULT_SEARCH_PATHS if isfile(expanduser(f))]
if not (config or urls) else config), asset=asset)
if not (config or urls) else config,
asset=asset))
# Load our inventory up
for url in urls:

View File

@ -154,6 +154,9 @@ class ConfigBase(URLBase):
# Dynamically load our parse_ function based on our config format
fn = getattr(ConfigBase, 'config_parse_{}'.format(config_format))
# Initialize our asset object
asset = asset if isinstance(asset, AppriseAsset) else self.asset
# Execute our config parse function which always returns a list
self._cached_servers.extend(fn(content=content, asset=asset))

View File

@ -27,6 +27,7 @@ import six
import mock
from apprise.config.ConfigFile import ConfigFile
from apprise.plugins.NotifyBase import NotifyBase
from apprise.AppriseAsset import AppriseAsset
# Disable logging for a cleaner testing output
import logging
@ -47,14 +48,20 @@ def test_config_file(tmpdir):
assert ConfigFile.parse_url('file://?') is None
# Create an Apprise asset we can reference
asset = AppriseAsset()
# Initialize our object
cf = ConfigFile(path=str(t), format='text')
cf = ConfigFile(path=str(t), format='text', asset=asset)
# one entry added
assert len(cf) == 1
assert isinstance(cf.url(), six.string_types) is True
# Verify that we're using the same asset
assert cf[0].asset is asset
# Testing of pop
cf = ConfigFile(path=str(t), format='text')