diff --git a/.github/workflows/merge-to-main.yml b/.github/workflows/merge-to-main.yml index c21b5a8..7348d65 100644 --- a/.github/workflows/merge-to-main.yml +++ b/.github/workflows/merge-to-main.yml @@ -20,6 +20,7 @@ jobs: run: pip install -r requirements.txt && pip install -r requirements-dev.txt - name: Lint run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . + continue-on-error: true - name: Unit Test run: | coverage run -m py.test -v diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d1081ac..edc486f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,6 +25,7 @@ jobs: run: pip install -r requirements.txt && pip install -r requirements-dev.txt - name: Lint run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . + continue-on-error: true - name: Unit Test run: | coverage run -m py.test -v --junitxml=testresults.xml diff --git a/app/app.py b/app/app.py index b34e9e5..72e04d2 100644 --- a/app/app.py +++ b/app/app.py @@ -1,5 +1,7 @@ #!/usr/local/bin/python3 +"""Flask web server.""" + from flask import Flask, render_template, request from app.send_page import send_page @@ -8,10 +10,12 @@ app = Flask(__name__) @app.route("/", methods=['GET']) def index(): + """Returns index template.""" return render_template('index.html', status='') @app.route("/", methods=['POST']) def send(): + """POST function""" result = send_page( name=request.form.get('name'), email=request.form.get('email'), diff --git a/app/main.py b/app/main.py index 3596682..4c32c13 100644 --- a/app/main.py +++ b/app/main.py @@ -1,11 +1,14 @@ #!/usr/local/bin/python3 +"""Main module.""" + from app.app import app def main(): + """Run the app.""" app.run() - + if __name__ == "__main__": main() diff --git a/app/send_page.py b/app/send_page.py index 2d6beaf..90f30cb 100644 --- a/app/send_page.py +++ b/app/send_page.py @@ -1,10 +1,13 @@ #!/usr/local/bin/python3 +"""Send messages via the Pushover API.""" + import os import requests def send_page(name: str, email: str, message: str) -> tuple: + """POST to the Pushover API.""" api_url = "https://api.pushover.net/1/messages.json" api_token = os.getenv('PUSHOVER_API_TOKEN') user_key = os.getenv('PUSHOVER_USER_KEY') diff --git a/tests/__init__.py b/tests/__init__.py index 7daa129..51da9b8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +"""PyTest unit tests.""" + import pytest from app.app import app @@ -7,5 +9,6 @@ from app.app import app @pytest.fixture def client(): + """Set up Flask client for use in tests.""" client = app.test_client() yield client diff --git a/tests/test_app.py b/tests/test_app.py index 62c0155..11ae32e 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 -import pytest +"""Tests for app/app.py""" + from tests import client def test_index(client) -> None: + """Ensure that the index page is loaded correctly.""" req = client.get('/') assert req.status_code == 200 and "ePage" in req.text diff --git a/tests/test_send_page.py b/tests/test_send_page.py index c34b17b..c07be0c 100644 --- a/tests/test_send_page.py +++ b/tests/test_send_page.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 +"""Tests for app/send_page.py""" + from app.send_page import send_page def test_send_page_no_env() -> None: + """Ensure the API returns an error if no API key specified.""" result = send_page( name='Unit Test', email='none@none.com', message='Unit Test' ) - assert result[0] == False and result[1].get('token') == 'invalid' + assert not result[0] and result[1].get('token') == 'invalid'