diff --git a/.github/workflows/pylint.yml b/.github/workflows/ci.yml similarity index 86% rename from .github/workflows/pylint.yml rename to .github/workflows/ci.yml index ac97ebf..8f8ebcb 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Pylint +name: Python CI on: [push] @@ -22,7 +22,10 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install -r test-requirements.txt pip install pylint - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') + - name: Run tests with pytest + run: pytest \ No newline at end of file diff --git a/test_main.py b/test_main.py index c37923c..7ac5f14 100644 --- a/test_main.py +++ b/test_main.py @@ -10,10 +10,11 @@ FILE_NAME = "sunflower.jpg" def test_read_main(): """Tests that POST /api/v1/detect returns 200 OK with valid request body""" - response = client.post( - "/api/v1/detect", - files={"file": (FILE_NAME, open(FILE_NAME, "rb"), "image/jpeg")}, - ) + with open(FILE_NAME, "rb") as file: + response = client.post( + "/api/v1/detect", + files={"file": (FILE_NAME, file, "image/jpeg")}, + ) assert response.status_code == 200 assert response.json() == { "file_name": FILE_NAME,