mirror of https://github.com/caronc/apprise
Chris Caron
4 years ago
committed by
GitHub
4 changed files with 258 additions and 0 deletions
@ -0,0 +1,42 @@
|
||||
# Apprise Development Tools |
||||
|
||||
This directory just contains some tools that are useful when developing with Apprise. The tools are as follows: |
||||
|
||||
- :gear: `apprise`: This effectively acts as the `apprise` tool would once Apprise has been installed into your environment. However `apprise` uses the branch you're working in. So if you added a new Notification service, you can test with it as you would easily. `apprise` takes all the same parameters as the `apprise` tool does. |
||||
|
||||
```bash |
||||
# simply make your code changes to apprise and test it out: |
||||
./bin/apprise -t title -m message \ |
||||
mailto://user:pass@example.com |
||||
``` |
||||
|
||||
- :gear: `test.sh`: This allows you to just run the unit tests associated with this project. You can optionally specify a _keyword_ as a parameter and the unit tests will specifically focus on a single test. This is useful when you need to debug something and don't want to run the entire fleet of tests each time. e.g: |
||||
|
||||
```bash |
||||
# Run all tests: |
||||
./bin/tests.sh |
||||
|
||||
# Run just the tests associated with the rest framework: |
||||
./bin/tests.sh rest |
||||
|
||||
# Run just the Apprise config related unit tests |
||||
./bin/tests.sh config |
||||
``` |
||||
|
||||
- :gear: `checkdone.sh`: This script just runs a lint check against the code to make sure there are no PEP8 issues and additionally runs a full test coverage report. This is what will happen once you check in your code. Nothing can be merged unless these tests pass with 100% coverage. So it's useful to have this handy to run now and then. |
||||
|
||||
```bash |
||||
# Perform PEP8 and test coverage check on all code and reports |
||||
# back. It's called 'checkdone' because it checks to see if you're |
||||
# actually done with your code commit or not. :) |
||||
./bin/checkdone.sh |
||||
``` |
||||
|
||||
You can optionally just update your path to include this `./bin` directory and call the scripts that way as well. Hence: |
||||
```bash |
||||
# Update the path to include the bin directory: |
||||
export PATH="$(pwd)/bin:$PATH" |
||||
|
||||
# Now you can call the scripts identified above from anywhere... |
||||
``` |
||||
|
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python |
||||
# -*- coding: utf-8 -*- |
||||
# |
||||
# Copyright (C) 2020 Chris Caron <lead2gold@gmail.com> |
||||
# All rights reserved. |
||||
# |
||||
# This code is licensed under the MIT License. |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
# of this software and associated documentation files(the "Software"), to deal |
||||
# in the Software without restriction, including without limitation the rights |
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell |
||||
# copies of the Software, and to permit persons to whom the Software is |
||||
# furnished to do so, subject to the following conditions : |
||||
# |
||||
# The above copyright notice and this permission notice shall be included in |
||||
# all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE |
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
# THE SOFTWARE. |
||||
|
||||
""" |
||||
This is a debug tool that allows one to test the apprise source code just |
||||
checked out. The script works out of the ./devel directory and will also work |
||||
if you just copy it back on directory and run it from the root. |
||||
""" |
||||
import sys |
||||
from os import getcwd |
||||
from os.path import join |
||||
from os.path import abspath |
||||
from os.path import dirname |
||||
|
||||
# |
||||
# Update path |
||||
# |
||||
|
||||
# First assume we might be in the ./devel directory |
||||
sys.path.insert( |
||||
0, join(dirname(dirname(abspath(__file__))), 'apprise')) # noqa |
||||
|
||||
# The user might have copied the apprise script back one directory |
||||
# so support this too.. |
||||
sys.path.insert( |
||||
0, join(dirname(abspath(__file__)), 'apprise')) # noqa |
||||
|
||||
# We can also use the current directory we're standing in as a last |
||||
# resort |
||||
sys.path.insert(0, join(getcwd(), 'apprise')) # noqa |
||||
|
||||
# Apprise tool now importable |
||||
from apprise.cli import main |
||||
import logging |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
# Logging |
||||
ch = logging.StreamHandler(sys.stdout) |
||||
logger = logging.getLogger(__name__) |
||||
|
||||
formatter = logging.Formatter( |
||||
'%(asctime)s - %(levelname)s - %(message)s') |
||||
ch.setFormatter(formatter) |
||||
logger.addHandler(ch) |
||||
logging.getLogger('apprise').setLevel(logger.getEffectiveLevel()) |
||||
|
||||
main() |
||||
exit(0) |
@ -0,0 +1,79 @@
|
||||
#!/bin/sh |
||||
# Copyright (C) 2020 Chris Caron <lead2gold@gmail.com> |
||||
# All rights reserved. |
||||
# |
||||
# This code is licensed under the MIT License. |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
# of this software and associated documentation files(the "Software"), to deal |
||||
# in the Software without restriction, including without limitation the rights |
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell |
||||
# copies of the Software, and to permit persons to whom the Software is |
||||
# furnished to do so, subject to the following conditions : |
||||
# |
||||
# The above copyright notice and this permission notice shall be included in |
||||
# all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE |
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
# THE SOFTWARE. |
||||
|
||||
# Absolute path to this script, e.g. /home/user/bin/foo.sh |
||||
SCRIPT=$(readlink -f "$0") |
||||
|
||||
# Absolute path this script is in, thus /home/user/bin |
||||
SCRIPTPATH=$(dirname "$SCRIPT") |
||||
|
||||
FOUNDROOT=1 |
||||
if [ -f "$(dirname $SCRIPTPATH)/setup.cfg" ]; then |
||||
pushd "$(dirname $SCRIPTPATH)" &>/dev/null |
||||
FOUNDROOT=$? |
||||
|
||||
elif [ -f "$SCRIPTPATH/setup.cfg" ]; then |
||||
pushd "$SCRIPTPATH" &>/dev/null |
||||
FOUNDROOT=$? |
||||
|
||||
fi |
||||
|
||||
if [ $FOUNDROOT -ne 0 ]; then |
||||
echo "Error: Could not locate apprise setup.cfg file." |
||||
exit 1 |
||||
fi |
||||
|
||||
# This is a useful tool for checking for any lint errors and additionally |
||||
# checking the overall coverage. |
||||
which flake8 &>/dev/null |
||||
[ $? -ne 0 ] && \ |
||||
echo "Missing flake8; make sure it is installed:" && \ |
||||
echo " > pip install flake8" && \ |
||||
exit 1 |
||||
|
||||
which coverage &>/dev/null |
||||
[ $? -ne 0 ] && \ |
||||
echo "Missing coverage; make sure it is installed:" && |
||||
echo " > pip install pytest-cov coverage" && \ |
||||
exit 1 |
||||
|
||||
echo "Performing PEP8 check..." |
||||
flake8 . --show-source --statistics |
||||
if [ $? -ne 0 ]; then |
||||
echo "PEP8 check failed" |
||||
exit 1 |
||||
fi |
||||
echo "PEP8 check succeeded; no errors found! :)" |
||||
echo |
||||
|
||||
# Run our unit test coverage check |
||||
echo "Running test coverage check..." |
||||
coverage run -m pytest -vv |
||||
if [ $? -ne 0 ]; then |
||||
echo "Tests failed." |
||||
exit 1 |
||||
fi |
||||
|
||||
# Print our report |
||||
coverage report --show-missing |
@ -0,0 +1,65 @@
|
||||
#!/bin/sh |
||||
# Copyright (C) 2020 Chris Caron <lead2gold@gmail.com> |
||||
# All rights reserved. |
||||
# |
||||
# This code is licensed under the MIT License. |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
# of this software and associated documentation files(the "Software"), to deal |
||||
# in the Software without restriction, including without limitation the rights |
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell |
||||
# copies of the Software, and to permit persons to whom the Software is |
||||
# furnished to do so, subject to the following conditions : |
||||
# |
||||
# The above copyright notice and this permission notice shall be included in |
||||
# all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE |
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
# THE SOFTWARE. |
||||
PYTEST=$(which py.test) |
||||
|
||||
# This script can basically be used to test individual tests that have |
||||
# been created. Just run the to run all tests: |
||||
# ./devel/test.sh |
||||
|
||||
# to key in on a specific test type: |
||||
# ./devel/test.sh <keyword> |
||||
|
||||
# Absolute path to this script, e.g. /home/user/bin/foo.sh |
||||
SCRIPT=$(readlink -f "$0") |
||||
|
||||
# Absolute path this script is in, thus /home/user/bin |
||||
SCRIPTPATH=$(dirname "$SCRIPT") |
||||
|
||||
PYTHONPATH="" |
||||
|
||||
if [ -f "$(dirname $SCRIPTPATH)/setup.cfg" ]; then |
||||
PYTHONPATH="$(dirname $SCRIPTPATH)" |
||||
|
||||
elif [ -f "$SCRIPTPATH/setup.cfg" ]; then |
||||
PYTHONPATH="$SCRIPTPATH" |
||||
|
||||
else |
||||
echo "Error: Could not locate apprise setup.cfg file." |
||||
exit 1 |
||||
fi |
||||
|
||||
if [ ! -x $PYTEST ]; then |
||||
echo "Error: $PYTEST was not found; make sure it is installed: 'pip3 install pytest'" |
||||
exit 1 |
||||
fi |
||||
|
||||
pushd $PYTHONPATH &>/dev/null |
||||
if [ ! -z "$@" ]; then |
||||
LANG=C.UTF-8 PYTHONPATH=$PYTHONPATH $PYTEST -k "$@" |
||||
exit $? |
||||
|
||||
else |
||||
LANG=C.UTF-8 PYTHONPATH=$PYTHONPATH $PYTEST |
||||
exit $? |
||||
fi |
Loading…
Reference in new issue