Github Actions Test Cases (#121)

This commit is contained in:
Chris Caron 2023-05-19 19:12:03 -04:00 committed by GitHub
parent 0f301272f2
commit 35553a9f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 144 additions and 36 deletions

View File

@ -1,12 +1,23 @@
[run]
data_file = .coverage-reports/.coverage
parallel = False
concurrency = multiprocessing
include = apprise_api
omit =
*apps.py,
*migrations/*,
*settings*,
*tests/*,
*/migrations/*,
*/core/settings/*,
lib/*,
lib64/*,
*urls.py,
*core/wsgi.py,
*/core/wsgi.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
View 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 }}

View File

@ -11,6 +11,7 @@ Apprise API was designed to easily fit into existing (and new) eco-systems that
[![Paypal](https://img.shields.io/badge/paypal-donate-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MHANV39UZNQ5E)
[![Follow](https://img.shields.io/twitter/follow/l2gnux)](https://twitter.com/l2gnux/)<br/>
[![Discord](https://img.shields.io/discord/558793703356104724.svg?colorB=7289DA&label=Discord&logo=Discord&logoColor=7289DA&style=flat-square)](https://discord.gg/MMPeN2D)
[![Build Status](https://github.com/caronc/apprise-api/actions/workflows/tests.yml/badge.svg)](https://github.com/caronc/apprise-api/actions/workflows/tests.yml)
[![CodeCov Status](https://codecov.io/github/caronc/apprise-api/branch/master/graph/badge.svg)](https://codecov.io/github/caronc/apprise-api)
[![Docker Pulls](https://img.shields.io/docker/pulls/caronc/apprise.svg?style=flat-square)](https://hub.docker.com/r/caronc/apprise)

View File

@ -491,8 +491,7 @@ class NotifyTests(SimpleTestCase):
'urls': ', '.join([
'mailto://user:pass@hotmail.com',
'mailto://user:pass@gmail.com',
],
),
]),
})
assert response.status_code == 200

View File

@ -99,7 +99,8 @@ class StatefulNotifyTests(SimpleTestCase):
form = NotifyForm(data=form_data)
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']
response = self.client.post(
@ -146,7 +147,8 @@ class StatefulNotifyTests(SimpleTestCase):
form = NotifyForm(data=form_data)
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']
response = self.client.post(

View File

@ -107,7 +107,7 @@ class StatelessNotifyTests(SimpleTestCase):
'urls': ', '.join([
'mailto://user:pass@hotmail.com',
'mailto://user:pass@gmail.com',
]),
]),
'body': 'test notifiction',
}

View File

@ -155,7 +155,7 @@ class DetailsView(View):
# Show All flag
# Support 'yes', '1', 'true', 'enable', 'active', and +
show_all = request.GET.get('all', 'no')[0].lower() in (
'a', 'y', '1', 't', 'e', '+')
'a', 'y', '1', 't', 'e', '+')
# Our status
status = ResponseCode.okay
@ -179,12 +179,12 @@ class DetailsView(View):
return render(request, self.template_name, {
'show_all': show_all,
'details': details,
}, status=status) if not json_response else \
}, status=status) if not json_response else \
JsonResponse(
details,
encoder=JSONEncoder,
safe=False,
status=status)
details,
encoder=JSONEncoder,
safe=False,
status=status)
@method_decorator(never_cache, name='dispatch')
@ -259,8 +259,8 @@ class AddView(View):
except (AttributeError, ValueError):
# could not parse JSON response...
return JsonResponse({
'error': _('Invalid JSON specified.'),
},
'error': _('Invalid JSON specified.'),
},
encoder=JSONEncoder,
safe=False,
status=ResponseCode.bad_request,
@ -387,12 +387,12 @@ class AddView(View):
status = ResponseCode.bad_request
return HttpResponse(msg, status=status) \
if not json_response else JsonResponse({
'error': msg,
},
encoder=JSONEncoder,
safe=False,
status=status,
)
'error': msg,
},
encoder=JSONEncoder,
safe=False,
status=status,
)
# 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.
@ -492,9 +492,9 @@ class GetView(View):
_('The site has been configured to deny this request.'),
status=ResponseCode.no_access,
) if not json_response else JsonResponse({
'error':
_('The site has been configured to deny this request.')
},
'error':
_('The site has been configured to deny this request.')
},
encoder=JSONEncoder,
safe=False,
status=ResponseCode.no_access,
@ -514,8 +514,7 @@ class GetView(View):
_('There was no configuration found.'),
status=ResponseCode.no_content,
) if not json_response else JsonResponse({
'error': _('There was no configuration found.')
},
'error': _('There was no configuration found.')},
encoder=JSONEncoder,
safe=False,
status=ResponseCode.no_content,
@ -547,9 +546,8 @@ class GetView(View):
content_type=content_type,
status=ResponseCode.okay,
) if not json_response else JsonResponse({
'format': format,
'config': config,
},
'format': format,
'config': config},
encoder=JSONEncoder,
safe=False,
status=ResponseCode.okay,

View File

@ -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
View 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