Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ip999 committed Jul 20, 2020
0 parents commit e11999f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application - tests

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest test.py
19 changes: 19 additions & 0 deletions hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from flask import Flask
from flask import make_response
app = Flask(__name__)


@app.route('/')
def home():
return "Hello World!\n"


@app.route('/<page_name>')
def other_page(page_name):
response = make_response('ERROR: The page named %s does not exist.'
% page_name, 404)
return response


if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from hello import app


def test_home():
tester = app.test_client()
response = tester.get('/', content_type='html/text')
assert response.status_code == 200
assert b'Hello World!' in response.data


def test_other():
tester = app.test_client()
response = tester.get('a', content_type='html/text')
assert response.status_code == 404
assert b'does not exist' in response.data

0 comments on commit e11999f

Please sign in to comment.