update GitHub WorkFlow

This commit is contained in:
2025-01-04 17:11:47 +01:00
parent 94b25b2807
commit 436d012475
2 changed files with 34 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
# 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
name: Python package
name: Test Quart Application
on:
push:
@@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
@@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
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
- name: Lint with flake8
@@ -38,7 +38,7 @@ jobs:
- name: Start Hypercorn for tests
run: |
nohup hypercorn -b 127.0.0.1:5000 app:app &
nohup hypercorn -b 127.0.0.1:8000 app:app &
sleep 5
- name: Test application with pytest
@@ -50,3 +50,4 @@ jobs:
run: |
pkill -f hypercorn

29
tests/test_app.py Normal file
View 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