i18n: complete UI/achievement keying, fix help_view tr() and i18n syntax errors
This commit is contained in:
@@ -4,13 +4,15 @@ utils.csv_importer 단위 테스트.
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from utils.csv_importer import parse_csv, _normalize_row, _normalize_time
|
||||
from utils.csv_importer import parse_csv, _normalize_row, _normalize_time, import_records
|
||||
from core.database import Database
|
||||
|
||||
|
||||
class TestNormalizeTime:
|
||||
@@ -125,3 +127,54 @@ class TestParseCsv:
|
||||
assert '줄 3' in str(exc.value)
|
||||
finally:
|
||||
os.remove(path)
|
||||
|
||||
|
||||
class TestImportRecords:
|
||||
def _db(self):
|
||||
p = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
|
||||
p.close()
|
||||
db = Database(p.name)
|
||||
db.save_settings({
|
||||
'work_minutes': '480',
|
||||
'lunch_duration_minutes': '60',
|
||||
'dinner_duration_minutes': '60',
|
||||
})
|
||||
return db, p.name
|
||||
|
||||
def test_overwrite_clears_overtime_usage(self):
|
||||
"""CSV 덮어쓰기 시 overtime_usage도 삭제되어 잔액이 일관성을 유지해야 함."""
|
||||
db, path = self._db()
|
||||
try:
|
||||
date_str = '2026-04-01'
|
||||
# 기존 기록 + 연장근무 사용 기록 생성
|
||||
wid = db.add_work_record(date_str, '09:00:00')
|
||||
db.update_clock_out(date_str, '20:00:00', 11.0, 120, 120)
|
||||
db.add_overtime_earned(wid, 120, date_str)
|
||||
db.add_overtime_usage(wid, 30, date_str, '테스트')
|
||||
|
||||
# 덮어쓰기 전 잔액
|
||||
balance_before = db.get_total_overtime_balance()
|
||||
assert balance_before == 90 # 120 적립 - 30 사용
|
||||
|
||||
rows = [{
|
||||
'date': date_str,
|
||||
'clock_in': '09:00:00',
|
||||
'clock_out': '18:00:00',
|
||||
'lunch_minutes': 60,
|
||||
'dinner_minutes': 0,
|
||||
'memo': '',
|
||||
}]
|
||||
import_records(db, rows, on_conflict='overwrite')
|
||||
|
||||
# 덮어쓰기 후 연장근무 사용 기록은 삭제되어야 함
|
||||
with db._conn() as conn:
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT COUNT(*) FROM overtime_usage WHERE date = ?", (date_str,))
|
||||
assert cur.fetchone()[0] == 0
|
||||
balance_after = db.get_total_overtime_balance()
|
||||
assert balance_after == 0 # 새 기록은 연장근무 없음
|
||||
finally:
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
@@ -162,5 +162,12 @@ class TestFetchNetwork:
|
||||
|
||||
|
||||
class TestConfigured:
|
||||
def test_key_set(self):
|
||||
assert is_configured() is True
|
||||
def test_key_set(self, monkeypatch):
|
||||
import utils.holiday_api as _ha
|
||||
monkeypatch.setattr(_ha, '_SERVICE_KEY', 'fa419259319e31d2fcd4f959e65da817fe2f19894bff340a63889db7a8ffac93')
|
||||
assert _ha.is_configured() is True
|
||||
|
||||
def test_key_empty(self, monkeypatch):
|
||||
import utils.holiday_api as _ha
|
||||
monkeypatch.setattr(_ha, '_SERVICE_KEY', '')
|
||||
assert _ha.is_configured() is False
|
||||
|
||||
Reference in New Issue
Block a user