mirror of https://github.com/caronc/apprise
minor fixes lingering from #1368
parent
b0fff4bc5b
commit
8dc7ba7bdb
|
@ -2,11 +2,13 @@
|
||||||
**Related issue (if applicable):** #<!--apprise issue number goes here-->
|
**Related issue (if applicable):** #<!--apprise issue number goes here-->
|
||||||
|
|
||||||
<!-- Have anything else to describe? Define it here; this helps build the wiki item later
|
<!-- Have anything else to describe? Define it here; this helps build the wiki item later
|
||||||
|
-- Delete this section if you are not creating a new plugin --
|
||||||
|
|
||||||
## *ServiceName* Notifications
|
## *ServiceName* Notifications
|
||||||
* **Source**: https://official.website.example.ca
|
* **Source**: https://official.website.example.ca
|
||||||
* **Icon Support**: No
|
* **Icon Support**: Yes / No
|
||||||
* **Message Format**: Plain Text
|
* **Message Format**: Plain Text / HTML / Markdown
|
||||||
* **Message Limit**: ~10,000 Characters
|
* **Message Limit**: nn Characters
|
||||||
|
|
||||||
Describe your service here..
|
Describe your service here..
|
||||||
|
|
||||||
|
@ -43,8 +45,6 @@ apprise -vv -t "Title" -b "Message content" \
|
||||||
service://token
|
service://token
|
||||||
```
|
```
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
## New Service Completion Status
|
## New Service Completion Status
|
||||||
<!-- This section is only applicable if you're adding a new service -->
|
<!-- This section is only applicable if you're adding a new service -->
|
||||||
* [ ] apprise/plugins/<!--new plugin name -->.py
|
* [ ] apprise/plugins/<!--new plugin name -->.py
|
||||||
|
@ -55,12 +55,14 @@ apprise -vv -t "Title" -b "Message content" \
|
||||||
* [ ] packaging/redhat/python-apprise.spec
|
* [ ] packaging/redhat/python-apprise.spec
|
||||||
- add new service into the `%global common_description`
|
- add new service into the `%global common_description`
|
||||||
|
|
||||||
|
-- END OF NEW PLUGIN SECTION - REMOVE ABOVE SECION IF NOT A NEW PLUGIN -->
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
<!-- The following must be completed or your PR can't be merged -->
|
<!-- The following must be completed or your PR can't be merged -->
|
||||||
* [ ] The code change is tested and works locally.
|
* [ ] The code change is tested and works locally.
|
||||||
* [ ] There is no commented out code in this PR.
|
* [ ] There is no commented out code in this PR.
|
||||||
* [ ] No lint errors (use `tox -e lint`)
|
* [ ] No lint errors (use `tox -e lint` and even `tox -e format` to autofix what it can)
|
||||||
* [ ] 100% test coverage (use `tox -e minimal`)
|
* [ ] Test coverage added (use `tox -e minimal`)
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
<!-- If this your code is testable by other users of the program
|
<!-- If this your code is testable by other users of the program
|
||||||
|
@ -83,5 +85,8 @@ pip install git+https://github.com/caronc/apprise.git@<this.branch-name>
|
||||||
apprise -t "Test Title" -b "Test Message" \
|
apprise -t "Test Title" -b "Test Message" \
|
||||||
<apprise url related to ticket>
|
<apprise url related to ticket>
|
||||||
|
|
||||||
|
# If you have cloned the branch and have tox available to you
|
||||||
|
# the following can also allow you to test:
|
||||||
|
tox -e apprise -- -t "Test Title" -b "Test Message" \
|
||||||
|
<apprise url related to ticket>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,7 @@ class Apprise:
|
||||||
self,
|
self,
|
||||||
body: Union[str, bytes],
|
body: Union[str, bytes],
|
||||||
title: Union[str, bytes] = "",
|
title: Union[str, bytes] = "",
|
||||||
notify_type: common.NotifyType = common.NotifyType.INFO,
|
notify_type: Union[str, common.NotifyType] = common.NotifyType.INFO,
|
||||||
body_format: Optional[str] = None,
|
body_format: Optional[str] = None,
|
||||||
tag: Any = common.MATCH_ALL_TAG,
|
tag: Any = common.MATCH_ALL_TAG,
|
||||||
match_always: bool = True,
|
match_always: bool = True,
|
||||||
|
@ -526,6 +526,18 @@ class Apprise:
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
|
try:
|
||||||
|
notify_type = (
|
||||||
|
notify_type if isinstance(notify_type, common.NotifyType)
|
||||||
|
else common.NotifyType(notify_type.lower())
|
||||||
|
)
|
||||||
|
|
||||||
|
except (AttributeError, ValueError, TypeError):
|
||||||
|
err = (
|
||||||
|
f"An invalid notification type ({notify_type}) was "
|
||||||
|
"specified.")
|
||||||
|
raise TypeError(err) from None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if title and isinstance(title, bytes):
|
if title and isinstance(title, bytes):
|
||||||
title = title.decode(self.asset.encoding)
|
title = title.decode(self.asset.encoding)
|
||||||
|
|
|
@ -286,10 +286,36 @@ def apprise_test(do_notify):
|
||||||
assert a.add("good://localhost") is True
|
assert a.add("good://localhost") is True
|
||||||
assert len(a) == 1
|
assert len(a) == 1
|
||||||
|
|
||||||
# Bad Notification Type is still allowed as it is presumed the user
|
# Bad Notification Types are not accepted
|
||||||
# know's what their doing
|
|
||||||
assert (
|
assert (
|
||||||
do_notify(a, title="my title", body="my body", notify_type="bad")
|
do_notify(a, title="my title", body="my body", notify_type="bad")
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
# Notifications of string type are accepted
|
||||||
|
assert (
|
||||||
|
do_notify(a, title="my title", body="my body", notify_type="warning")
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Notifications of string type are accepted
|
||||||
|
assert (
|
||||||
|
do_notify(a, title="my title", body="my body", notify_type="warning")
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Notifications of string type are accepted
|
||||||
|
assert (
|
||||||
|
do_notify(a, title="my title", body="my body", notify_type="warning")
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Notifications where notify_type is of the NotifyType object is the
|
||||||
|
# preferred choice
|
||||||
|
assert (
|
||||||
|
do_notify(
|
||||||
|
a, title="my title", body="my body",
|
||||||
|
notify_type=NotifyType.WARNING)
|
||||||
is True
|
is True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2008,7 +2008,7 @@ def test_apprise_cli_plugin_loading(mock_post, tmpdir):
|
||||||
@notify(on="clihook")
|
@notify(on="clihook")
|
||||||
def mywrapper(body, title, notify_type, *args, **kwargs):
|
def mywrapper(body, title, notify_type, *args, **kwargs):
|
||||||
# A simple test - print to screen
|
# A simple test - print to screen
|
||||||
print("{}: {} - {}".format(notify_type, title, body))
|
print("{}: {} - {}".format(notify_type.value, title, body))
|
||||||
|
|
||||||
# No return (so a return of None) get's translated to True
|
# No return (so a return of None) get's translated to True
|
||||||
|
|
||||||
|
@ -2016,7 +2016,7 @@ def test_apprise_cli_plugin_loading(mock_post, tmpdir):
|
||||||
@notify(on="clihookA")
|
@notify(on="clihookA")
|
||||||
def mywrapper(body, title, notify_type, *args, **kwargs):
|
def mywrapper(body, title, notify_type, *args, **kwargs):
|
||||||
# A simple test - print to screen
|
# A simple test - print to screen
|
||||||
print("!! {}: {} - {}".format(notify_type, title, body))
|
print("!! {}: {} - {}".format(notify_type.value, title, body))
|
||||||
|
|
||||||
# No return (so a return of None) get's translated to True
|
# No return (so a return of None) get's translated to True
|
||||||
"""))
|
"""))
|
||||||
|
@ -2286,6 +2286,37 @@ def test_apprise_cli_plugin_loading(mock_post, tmpdir):
|
||||||
# to the CLI
|
# to the CLI
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
result = runner.invoke(
|
||||||
|
cli.main,
|
||||||
|
[
|
||||||
|
"--plugin-path",
|
||||||
|
join(str(tmpdir), "complex"),
|
||||||
|
"--notification-type", "invalid",
|
||||||
|
"-b",
|
||||||
|
"test body",
|
||||||
|
# our clihook that returns true
|
||||||
|
"clihook1://",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
# Bad notification type specified
|
||||||
|
assert result.exit_code == 2
|
||||||
|
|
||||||
|
result = runner.invoke(
|
||||||
|
cli.main,
|
||||||
|
[
|
||||||
|
"--plugin-path",
|
||||||
|
join(str(tmpdir), "complex"),
|
||||||
|
"-b",
|
||||||
|
"-i", "warning"
|
||||||
|
"test body",
|
||||||
|
# our clihook that returns true
|
||||||
|
"clihook1://",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
# Bad notification type specified
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
cli.main,
|
cli.main,
|
||||||
[
|
[
|
||||||
|
|
8
tox.ini
8
tox.ini
|
@ -87,6 +87,13 @@ commands =
|
||||||
coverage run --source=apprise -m pytest tests {posargs}
|
coverage run --source=apprise -m pytest tests {posargs}
|
||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
|
[testenv:test]
|
||||||
|
description = Run simplified tests without coverage
|
||||||
|
extras = dev,all-plugins
|
||||||
|
commands =
|
||||||
|
pip install --no-cache-dir -e ".[dev,all-plugins]"
|
||||||
|
pytest --tb=short -q {posargs}
|
||||||
|
|
||||||
[testenv:clean]
|
[testenv:clean]
|
||||||
description = Remove build artifacts and cache files
|
description = Remove build artifacts and cache files
|
||||||
skip_install = true
|
skip_install = true
|
||||||
|
@ -96,6 +103,7 @@ allowlist_externals =
|
||||||
commands =
|
commands =
|
||||||
find . -type f -name "*.pyc" -delete
|
find . -type f -name "*.pyc" -delete
|
||||||
find . -type f -name "*.pyo" -delete
|
find . -type f -name "*.pyo" -delete
|
||||||
|
find . -type f -name "*.orig" -delete
|
||||||
find . -type d -name "__pycache__" -delete
|
find . -type d -name "__pycache__" -delete
|
||||||
rm -rf BUILD SOURCES SRPMS BUILDROOT .cache .ruff_cache .coverage-reports .coverage coverage.xml dist build apprise.egg-info .mypy_cache .pytest_cache
|
rm -rf BUILD SOURCES SRPMS BUILDROOT .cache .ruff_cache .coverage-reports .coverage coverage.xml dist build apprise.egg-info .mypy_cache .pytest_cache
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue