Skip to content

Commit 983172b

Browse files
authored
Merge pull request #58 from tisnik/unit-test-for-uvicorn-runner
Unit test for Uvicorn runner
2 parents 3843c46 + 6d95ed1 commit 983172b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Unit tests for runners."""
2+
3+
from unittest.mock import patch
4+
5+
import pytest
6+
7+
from runners.uvicorn import start_uvicorn
8+
9+
10+
def test_start_uvicorn() -> None:
11+
"""Test the function to start Uvicorn server."""
12+
# don't start real Uvicorn server
13+
with patch("uvicorn.run") as mocked_run:
14+
start_uvicorn()
15+
mocked_run.assert_called_once_with(
16+
"app.main:app",
17+
host="localhost",
18+
port=8080,
19+
workers=1,
20+
log_level=20,
21+
use_colors=True,
22+
access_log=True,
23+
)

0 commit comments

Comments
 (0)