41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
날씨 DB 기능 테스트
|
|
"""
|
|
|
|
from database.crud import CRUDManager
|
|
from datetime import datetime
|
|
|
|
def test_weather_db():
|
|
"""날씨 DB 기능 테스트"""
|
|
crud = CRUDManager()
|
|
|
|
# 테스트 날씨 데이터 저장
|
|
test_datetime = datetime(2026, 1, 10, 12, 0)
|
|
weather = crud.upsert_weather(
|
|
datetime=test_datetime,
|
|
location_name='부산',
|
|
location_code='2638057200',
|
|
temp=15,
|
|
feels_like=16,
|
|
weather_condition='맑음',
|
|
weather_icon='☀️'
|
|
)
|
|
print(f'Weather data saved: {weather.temp}°C, {weather.weather_condition}')
|
|
|
|
# 저장된 데이터 조회
|
|
weather_data = crud.get_weather_by_datetime_range(
|
|
start_datetime=datetime(2026, 1, 10, 0, 0),
|
|
end_datetime=datetime(2026, 1, 10, 23, 59),
|
|
location_code='2638057200'
|
|
)
|
|
print(f'Found {len(weather_data)} weather records')
|
|
|
|
# 근무 형태별 통계 조회
|
|
stats = crud.get_weather_stats_for_shift('주간', datetime(2026, 1, 10).date(), '2638057200')
|
|
print(f'Shift stats: {stats}')
|
|
|
|
if __name__ == '__main__':
|
|
test_weather_db()
|