From 068d2cd1219900a079dbf67daed167e12d55f846 Mon Sep 17 00:00:00 2001 From: Melyns <60199831+Melyns@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:32:35 +0100 Subject: [PATCH] Update ci-linux.yml --- .github/workflows/ci-linux.yml | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index ea3d5ae..f3afe2e 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -1,29 +1,28 @@ -name: CI +import sys +import os -on: [push, pull_request] +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -jobs: - test: - runs-on: ubuntu-latest +from fastapi.testclient import TestClient +from app import app - steps: - - name: Checkout code - uses: actions/checkout@v3 +client = TestClient(app) - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' +def test_index(): + response = client.get("/") + assert response.status_code == 200 + assert "Welcome" in response.text - - name: Install dependencies - run: | - pip install fastapi uvicorn requests pytest httpx +def test_new_chat(): + response = client.post("/new-chat") + assert response.status_code == 200 + assert response.json() == {"status": "new chat started"} - - name: Run tests - run: | - pytest .github/ --maxfail=1 --disable-warnings -q +def test_pause(): + response = client.post("/pause") + assert response.status_code == 200 + assert response.json()["paused"] is True - - name: Lint code - run: | - pip install pylint - pylint app.py + response = client.post("/pause") + assert response.status_code == 200 + assert response.json()["paused"] is False