import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) import persons_tree def test_parse_year_iso_string(): assert persons_tree._parse_year("1920-09-20") == 1920 def test_parse_year_excel_serial_birth(): # 7568 days from 1899-12-30 = 1920-09-19 or -20 depending on leap counting assert persons_tree._parse_year("7568") == 1920 def test_parse_year_excel_serial_death(): # 36222 days from 1899-12-30 ≈ 1999 assert persons_tree._parse_year("36222") == 1999 def test_parse_year_excel_serial_small(): # 177 days from 1899-12-30 = 1900-06-25 assert persons_tree._parse_year("177") == 1900 def test_parse_year_german_date_string(): assert persons_tree._parse_year("30.8.1862") == 1862 def test_parse_year_year_only(): assert persons_tree._parse_year("1930") == 1930 def test_parse_year_free_text(): assert persons_tree._parse_year("August 1941") == 1941 def test_parse_year_none(): assert persons_tree._parse_year(None) is None def test_parse_year_empty(): assert persons_tree._parse_year("") is None def test_parse_year_unresolvable_truncated(): # "2.9.196" has no valid 4-digit year — returns None assert persons_tree._parse_year("2.9.196") is None def test_parse_year_typo_year(): # "4.3.1023" — year 1023 outside 1500-2100 guard — returns None assert persons_tree._parse_year("4.3.1023") is None