mirror of
https://github.com/caronc/apprise.git
synced 2025-06-26 04:31:57 +02:00
Asset passed into AppriseConfig() is now recognized (#272)
This commit is contained in:
parent
e65b1dc5af
commit
4f4b15d47e
@ -204,7 +204,8 @@ def main(body, title, config, attach, urls, notification_type, theme, tag,
|
|||||||
# identified on the command line
|
# identified on the command line
|
||||||
a.add(AppriseConfig(
|
a.add(AppriseConfig(
|
||||||
paths=[f for f in DEFAULT_SEARCH_PATHS if isfile(expanduser(f))]
|
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
|
# Load our inventory up
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
@ -154,6 +154,9 @@ class ConfigBase(URLBase):
|
|||||||
# Dynamically load our parse_ function based on our config format
|
# Dynamically load our parse_ function based on our config format
|
||||||
fn = getattr(ConfigBase, 'config_parse_{}'.format(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
|
# Execute our config parse function which always returns a list
|
||||||
self._cached_servers.extend(fn(content=content, asset=asset))
|
self._cached_servers.extend(fn(content=content, asset=asset))
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import six
|
|||||||
import mock
|
import mock
|
||||||
from apprise.config.ConfigFile import ConfigFile
|
from apprise.config.ConfigFile import ConfigFile
|
||||||
from apprise.plugins.NotifyBase import NotifyBase
|
from apprise.plugins.NotifyBase import NotifyBase
|
||||||
|
from apprise.AppriseAsset import AppriseAsset
|
||||||
|
|
||||||
# Disable logging for a cleaner testing output
|
# Disable logging for a cleaner testing output
|
||||||
import logging
|
import logging
|
||||||
@ -47,14 +48,20 @@ def test_config_file(tmpdir):
|
|||||||
|
|
||||||
assert ConfigFile.parse_url('file://?') is None
|
assert ConfigFile.parse_url('file://?') is None
|
||||||
|
|
||||||
|
# Create an Apprise asset we can reference
|
||||||
|
asset = AppriseAsset()
|
||||||
|
|
||||||
# Initialize our object
|
# Initialize our object
|
||||||
cf = ConfigFile(path=str(t), format='text')
|
cf = ConfigFile(path=str(t), format='text', asset=asset)
|
||||||
|
|
||||||
# one entry added
|
# one entry added
|
||||||
assert len(cf) == 1
|
assert len(cf) == 1
|
||||||
|
|
||||||
assert isinstance(cf.url(), six.string_types) is True
|
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
|
# Testing of pop
|
||||||
cf = ConfigFile(path=str(t), format='text')
|
cf = ConfigFile(path=str(t), format='text')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user