Skip to content

Commit f84eff5

Browse files
committed
testing pytest.
1 parent d4ef997 commit f84eff5

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

.github/workflows/github-actions-demo.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
with:
2727
options: '--check --verbose'
2828
src: './app'
29+
- name: Run pytest
30+
run: |
31+
pytest ./tests
2932
- name: Print sunrise/sunset data
3033
run: |
3134
python ./app/main.py

app/config/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Configuration settings for the application.
33
"""
44

5-
from pydantic_settings import BaseSettings
65
from pydantic import HttpUrl
6+
from pydantic_settings import BaseSettings
77

88

99
class Settings(BaseSettings):

app/main.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""
2-
Docstring for main.py
2+
This is the main entry point for the application.
33
"""
4-
import aiohttp
54
import asyncio
6-
from result import Ok, Err, Result
7-
from schemas.sun_results import SunResults
8-
from pydantic import ValidationError
9-
from config.settings import Settings
5+
6+
import aiohttp
107
from icecream import ic, install
8+
from pydantic import ValidationError
9+
from result import Err, Ok, Result
10+
11+
from app.config.settings import Settings
12+
from app.schemas.sun_results import SunResults
1113

1214

1315
async def get_sun_times() -> Result[SunResults, str]:

tests/__init__.py

Whitespace-only changes.

tests/main_test.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
Testing settings.
3+
"""
4+
from app.config.settings import Settings
5+
from pydantic import HttpUrl
6+
7+
8+
def test_settings():
9+
settings = Settings()
10+
assert settings.TEST_URL == HttpUrl(
11+
"https://api.sunrisesunset.io/json?lat=29.7604&lng=-95.3698&timezone=America/Chicago&date=today"
12+
)

0 commit comments

Comments
 (0)