Skip to content

Commit 7a87ccc

Browse files
committed
Add python test
1 parent 13e7370 commit 7a87ccc

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

.github/workflows/python.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Python - Lint and Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "code/function/**"
8+
- "tests/**"
9+
- "requirements.txt"
10+
- ".github/workflows/python.yml"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- "code/function/**"
16+
- "tests/**"
17+
- "requirements.txt"
18+
- ".github/workflows/python.yml"
19+
20+
jobs:
21+
lint:
22+
name: Lint and Test
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
# Setup Python 3.10
27+
- name: Setup Python 3.10
28+
id: python_setup
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.10"
32+
33+
# Checkout repository
34+
- name: Check Out Repository
35+
id: checkout_repository
36+
uses: actions/checkout@v3
37+
38+
# Run Python Tests
39+
- name: Run Python Tests
40+
id: python_test
41+
run: |
42+
pip install -r requirements.txt -q
43+
python -m pytest

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pre-commit~=3.3.2
2+
pytest~=7.3.1

tests/test_main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
from fastapi.testclient import TestClient
3+
4+
from code.function.core.config import settings
5+
from code.function.main import app
6+
7+
8+
@pytest.fixture(scope="module")
9+
def client() -> TestClient:
10+
return TestClient(app)
11+
12+
13+
@pytest.mark.parametrize("version", ("v1",))
14+
def test_get_heartbeat(client, version):
15+
# arrange
16+
path = f"/corrector/{version}/heartbeat"
17+
18+
# action
19+
response = client.get(path)
20+
21+
# assert
22+
assert response.status_code == 200
23+
assert response.json() == {"isAlive": True}

0 commit comments

Comments
 (0)