update GitHub WorkFlow
This commit is contained in:
9
.github/workflows/python-package.yml
vendored
9
.github/workflows/python-package.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||||
|
|
||||||
name: Python package
|
name: Test Quart Application
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.10"]
|
python-version: ["3.10", "3.11"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install flake8 pytest httpx hypercorn
|
python -m pip install flake8 pytest httpx hypercorn pytest-asyncio
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Start Hypercorn for tests
|
- name: Start Hypercorn for tests
|
||||||
run: |
|
run: |
|
||||||
nohup hypercorn -b 127.0.0.1:5000 app:app &
|
nohup hypercorn -b 127.0.0.1:8000 app:app &
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
- name: Test application with pytest
|
- name: Test application with pytest
|
||||||
@@ -50,3 +50,4 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pkill -f hypercorn
|
pkill -f hypercorn
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
tests/test_app.py
Normal file
29
tests/test_app.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright Hersel Giannella
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
BASE_URL = "http://127.0.0.1:5000"
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_home_route():
|
||||||
|
"""
|
||||||
|
Testa la route principale del Blueprint `route_home`.
|
||||||
|
"""
|
||||||
|
async with httpx.AsyncClient(base_url=BASE_URL) as client:
|
||||||
|
response = await client.get("/")
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert "Welcome" in response.text
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_404_route():
|
||||||
|
"""
|
||||||
|
Verifica la gestione di una route inesistente.
|
||||||
|
"""
|
||||||
|
async with httpx.AsyncClient(base_url=BASE_URL) as client:
|
||||||
|
response = await client.get("/nonexistent")
|
||||||
|
assert response.status_code == 404
|
||||||
|
|
||||||
Reference in New Issue
Block a user