mirror of
https://github.com/caronc/apprise-api.git
synced 2025-08-14 00:38:21 +02:00
Github Actions Test Cases (#121)
This commit is contained in:
21
.coveragerc
21
.coveragerc
@ -1,12 +1,23 @@
|
|||||||
[run]
|
[run]
|
||||||
|
data_file = .coverage-reports/.coverage
|
||||||
|
parallel = False
|
||||||
|
concurrency = multiprocessing
|
||||||
|
include = apprise_api
|
||||||
omit =
|
omit =
|
||||||
*apps.py,
|
*apps.py,
|
||||||
*migrations/*,
|
*/migrations/*,
|
||||||
*settings*,
|
*/core/settings/*,
|
||||||
*tests/*,
|
|
||||||
lib/*,
|
lib/*,
|
||||||
lib64/*,
|
lib64/*,
|
||||||
*urls.py,
|
*urls.py,
|
||||||
*core/wsgi.py,
|
*/core/wsgi.py,
|
||||||
gunicorn.conf.py,
|
gunicorn.conf.py,
|
||||||
manage.py
|
*/manage.py
|
||||||
|
|
||||||
|
disable_warnings = no-data-collected
|
||||||
|
|
||||||
|
[report]
|
||||||
|
show_missing = True
|
||||||
|
skip_covered = True
|
||||||
|
skip_empty = True
|
||||||
|
fail_under = 75.0
|
||||||
|
82
.github/workflows/tests.yml
vendored
Normal file
82
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
|
||||||
|
# On which repository actions to trigger the build.
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
# Allow job to be triggered manually.
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Cancel in-progress jobs when pushing to the same branch.
|
||||||
|
concurrency:
|
||||||
|
cancel-in-progress: true
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
tests:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
|
||||||
|
# Run all jobs to completion (false), or cancel
|
||||||
|
# all jobs once the first one fails (true).
|
||||||
|
fail-fast: true
|
||||||
|
|
||||||
|
# Define a minimal test matrix, it will be
|
||||||
|
# expanded using subsequent `include` items.
|
||||||
|
matrix:
|
||||||
|
os: ["ubuntu-latest"]
|
||||||
|
python-version: ["3.10"]
|
||||||
|
bare: [false]
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
env:
|
||||||
|
OS: ${{ matrix.os }}
|
||||||
|
PYTHON: ${{ matrix.python-version }}
|
||||||
|
BARE: ${{ matrix.bare }}
|
||||||
|
|
||||||
|
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} ${{ matrix.bare && '(bare)' || '' }}
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Acquire sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install prerequisites (Linux)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install project dependencies (Baseline)
|
||||||
|
run: |
|
||||||
|
pip install -r requirements.txt -r dev-requirements.txt
|
||||||
|
|
||||||
|
# For saving resources, code style checking is
|
||||||
|
# only invoked within the `bare` environment.
|
||||||
|
- name: Check code style
|
||||||
|
if: matrix.bare == true
|
||||||
|
run: |
|
||||||
|
flake8 apprise_api --count --show-source --statistics
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
coverage run -m pytest apprise_api
|
||||||
|
|
||||||
|
- name: Process coverage data
|
||||||
|
run: |
|
||||||
|
coverage xml
|
||||||
|
coverage report
|
||||||
|
|
||||||
|
- name: Upload coverage data
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./coverage.xml
|
||||||
|
fail_ci_if_error: false
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
@ -11,6 +11,7 @@ Apprise API was designed to easily fit into existing (and new) eco-systems that
|
|||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MHANV39UZNQ5E)
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MHANV39UZNQ5E)
|
||||||
[](https://twitter.com/l2gnux/)<br/>
|
[](https://twitter.com/l2gnux/)<br/>
|
||||||
[](https://discord.gg/MMPeN2D)
|
[](https://discord.gg/MMPeN2D)
|
||||||
|
[](https://github.com/caronc/apprise-api/actions/workflows/tests.yml)
|
||||||
[](https://codecov.io/github/caronc/apprise-api)
|
[](https://codecov.io/github/caronc/apprise-api)
|
||||||
[](https://hub.docker.com/r/caronc/apprise)
|
[](https://hub.docker.com/r/caronc/apprise)
|
||||||
|
|
||||||
|
@ -491,8 +491,7 @@ class NotifyTests(SimpleTestCase):
|
|||||||
'urls': ', '.join([
|
'urls': ', '.join([
|
||||||
'mailto://user:pass@hotmail.com',
|
'mailto://user:pass@hotmail.com',
|
||||||
'mailto://user:pass@gmail.com',
|
'mailto://user:pass@gmail.com',
|
||||||
],
|
]),
|
||||||
),
|
|
||||||
})
|
})
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
@ -99,7 +99,8 @@ class StatefulNotifyTests(SimpleTestCase):
|
|||||||
form = NotifyForm(data=form_data)
|
form = NotifyForm(data=form_data)
|
||||||
assert form.is_valid()
|
assert form.is_valid()
|
||||||
|
|
||||||
# Required to prevent None from being passed into self.client.post()
|
# Required to prevent None from being passed into
|
||||||
|
# self.client.post()
|
||||||
del form.cleaned_data['attachment']
|
del form.cleaned_data['attachment']
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
@ -146,7 +147,8 @@ class StatefulNotifyTests(SimpleTestCase):
|
|||||||
form = NotifyForm(data=form_data)
|
form = NotifyForm(data=form_data)
|
||||||
assert form.is_valid()
|
assert form.is_valid()
|
||||||
|
|
||||||
# Required to prevent None from being passed into self.client.post()
|
# Required to prevent None from being passed into
|
||||||
|
# self.client.post()
|
||||||
del form.cleaned_data['attachment']
|
del form.cleaned_data['attachment']
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
|
@ -107,7 +107,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
|||||||
'urls': ', '.join([
|
'urls': ', '.join([
|
||||||
'mailto://user:pass@hotmail.com',
|
'mailto://user:pass@hotmail.com',
|
||||||
'mailto://user:pass@gmail.com',
|
'mailto://user:pass@gmail.com',
|
||||||
]),
|
]),
|
||||||
'body': 'test notifiction',
|
'body': 'test notifiction',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ class DetailsView(View):
|
|||||||
# Show All flag
|
# Show All flag
|
||||||
# Support 'yes', '1', 'true', 'enable', 'active', and +
|
# Support 'yes', '1', 'true', 'enable', 'active', and +
|
||||||
show_all = request.GET.get('all', 'no')[0].lower() in (
|
show_all = request.GET.get('all', 'no')[0].lower() in (
|
||||||
'a', 'y', '1', 't', 'e', '+')
|
'a', 'y', '1', 't', 'e', '+')
|
||||||
|
|
||||||
# Our status
|
# Our status
|
||||||
status = ResponseCode.okay
|
status = ResponseCode.okay
|
||||||
@ -179,12 +179,12 @@ class DetailsView(View):
|
|||||||
return render(request, self.template_name, {
|
return render(request, self.template_name, {
|
||||||
'show_all': show_all,
|
'show_all': show_all,
|
||||||
'details': details,
|
'details': details,
|
||||||
}, status=status) if not json_response else \
|
}, status=status) if not json_response else \
|
||||||
JsonResponse(
|
JsonResponse(
|
||||||
details,
|
details,
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=status)
|
status=status)
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(never_cache, name='dispatch')
|
@method_decorator(never_cache, name='dispatch')
|
||||||
@ -259,8 +259,8 @@ class AddView(View):
|
|||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
# could not parse JSON response...
|
# could not parse JSON response...
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'error': _('Invalid JSON specified.'),
|
'error': _('Invalid JSON specified.'),
|
||||||
},
|
},
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=ResponseCode.bad_request,
|
status=ResponseCode.bad_request,
|
||||||
@ -387,12 +387,12 @@ class AddView(View):
|
|||||||
status = ResponseCode.bad_request
|
status = ResponseCode.bad_request
|
||||||
return HttpResponse(msg, status=status) \
|
return HttpResponse(msg, status=status) \
|
||||||
if not json_response else JsonResponse({
|
if not json_response else JsonResponse({
|
||||||
'error': msg,
|
'error': msg,
|
||||||
},
|
},
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=status,
|
status=status,
|
||||||
)
|
)
|
||||||
|
|
||||||
# If we reach here; we successfully loaded the configuration so we can
|
# If we reach here; we successfully loaded the configuration so we can
|
||||||
# go ahead and write it to disk and alert our caller of the success.
|
# go ahead and write it to disk and alert our caller of the success.
|
||||||
@ -492,9 +492,9 @@ class GetView(View):
|
|||||||
_('The site has been configured to deny this request.'),
|
_('The site has been configured to deny this request.'),
|
||||||
status=ResponseCode.no_access,
|
status=ResponseCode.no_access,
|
||||||
) if not json_response else JsonResponse({
|
) if not json_response else JsonResponse({
|
||||||
'error':
|
'error':
|
||||||
_('The site has been configured to deny this request.')
|
_('The site has been configured to deny this request.')
|
||||||
},
|
},
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=ResponseCode.no_access,
|
status=ResponseCode.no_access,
|
||||||
@ -514,8 +514,7 @@ class GetView(View):
|
|||||||
_('There was no configuration found.'),
|
_('There was no configuration found.'),
|
||||||
status=ResponseCode.no_content,
|
status=ResponseCode.no_content,
|
||||||
) if not json_response else JsonResponse({
|
) if not json_response else JsonResponse({
|
||||||
'error': _('There was no configuration found.')
|
'error': _('There was no configuration found.')},
|
||||||
},
|
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=ResponseCode.no_content,
|
status=ResponseCode.no_content,
|
||||||
@ -547,9 +546,8 @@ class GetView(View):
|
|||||||
content_type=content_type,
|
content_type=content_type,
|
||||||
status=ResponseCode.okay,
|
status=ResponseCode.okay,
|
||||||
) if not json_response else JsonResponse({
|
) if not json_response else JsonResponse({
|
||||||
'format': format,
|
'format': format,
|
||||||
'config': config,
|
'config': config},
|
||||||
},
|
|
||||||
encoder=JSONEncoder,
|
encoder=JSONEncoder,
|
||||||
safe=False,
|
safe=False,
|
||||||
status=ResponseCode.okay,
|
status=ResponseCode.okay,
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
DJANGO_SETTINGS_MODULE = core.settings.pytest
|
|
||||||
addopts = --nomigrations --cov=. --cov-report=term-missing
|
|
||||||
python_files = tests.py test_*.py *_tests.py
|
|
19
setup.cfg
Normal file
19
setup.cfg
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[metadata]
|
||||||
|
# ensure LICENSE is included in wheel metadata
|
||||||
|
license_file = LICENSE
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
# We exclude packages we don't maintain
|
||||||
|
exclude = .eggs,.tox
|
||||||
|
ignore = E741,E722,W503,W504,W605
|
||||||
|
statistics = true
|
||||||
|
builtins = _
|
||||||
|
|
||||||
|
[aliases]
|
||||||
|
test=pytest
|
||||||
|
|
||||||
|
[tool:pytest]
|
||||||
|
DJANGO_SETTINGS_MODULE = core.settings.pytest
|
||||||
|
addopts = --ignore=lib --ignore=lib64 --nomigrations --cov=apprise_api --cov-report=term-missing
|
||||||
|
filterwarnings =
|
||||||
|
once::Warning
|
Reference in New Issue
Block a user