Skip to content

Commit

Permalink
unittest instead of pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
MayNiklas committed Jul 27, 2024
1 parent a148cfb commit 20ac86a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 63 deletions.
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.unittestEnabled": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ python3 -m venv .venv
source .venv/bin/activate
# prepare the environment
pip3 install -e .
pip3 install -e '.[dev]'
# run the server from within the virtual environment
cd src/
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def read_version(fname="src/whisper_api/version.py"):
include_package_data=True,
extras_require={
"dev": [
"pytest",
"pre-commit",
"autopep8"
"autopep8",
"httpx",
"pre-commit"
]
},
)
Empty file added test/__init__.py
Empty file.
43 changes: 43 additions & 0 deletions test/test_frontend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import unittest
from fastapi.testclient import TestClient
from whisper_api import app

"""
Test that the frontend files are served correctly.
"""

client = TestClient(app)


class TestFrontend(unittest.TestCase):

def test_index_html(self):
"""
Test that the index.html file is served correctly.
"""
response = client.get("/index.html")
assert response.status_code == 200
assert response.headers["content-type"] == "text/html; charset=utf-8"

def test_script_js(self):
"""
Test that the script.js file is served correctly.
"""
response = client.get("/script.js")
assert response.status_code == 200
assert response.headers["content-type"] == "text/javascript; charset=utf-8"

def test_styles_css(self):
"""
Test that the styles.css file is served correctly.
"""
response = client.get("/styles.css")
assert response.status_code == 200
assert response.headers["content-type"] == "text/css; charset=utf-8"

def test_not_found(self):
"""
Test that a 404 error is returned when a file is not found.
"""
response = client.get("/not_found")
assert response.status_code == 404
11 changes: 11 additions & 0 deletions test/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest


class TestImport(unittest.TestCase):

def test_import_whisper_api(self):
try:
import whisper_api
assert whisper_api
except ImportError:
unittest.fail("Failed to import whisper_api")
45 changes: 0 additions & 45 deletions tests/test_frontend.py

This file was deleted.

9 changes: 0 additions & 9 deletions tests/test_import.py

This file was deleted.

0 comments on commit 20ac86a

Please sign in to comment.