初始提交:飞球 ETL 系统全量代码

This commit is contained in:
Neo
2026-02-13 08:05:34 +08:00
commit 3c51f5485d
441 changed files with 117631 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""解析器测试"""
import pytest
from decimal import Decimal
from datetime import datetime
from zoneinfo import ZoneInfo
from models.parsers import TypeParser
def test_parse_decimal():
"""测试金额解析"""
assert TypeParser.parse_decimal("100.555", 2) == Decimal("100.56")
assert TypeParser.parse_decimal(None) is None
assert TypeParser.parse_decimal("invalid") is None
def test_parse_int():
"""测试整数解析"""
assert TypeParser.parse_int("123") == 123
assert TypeParser.parse_int(456) == 456
assert TypeParser.parse_int(None) is None
assert TypeParser.parse_int("abc") is None
def test_parse_timestamp():
"""测试时间戳解析"""
tz = ZoneInfo("Asia/Taipei")
dt = TypeParser.parse_timestamp("2025-01-15 10:30:00", tz)
assert dt is not None
assert dt.year == 2025
assert dt.month == 1
assert dt.day == 15
def test_parse_timestamp_zero_epoch():
"""0 不应被当成空值;应解析为 Unix epoch。"""
tz = ZoneInfo("Asia/Taipei")
dt = TypeParser.parse_timestamp(0, tz)
assert dt is not None
assert dt.year == 1970
assert dt.month == 1
assert dt.day == 1