Initializes GEDCOM to Markdown converter project #1
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
testpaths = tests
|
testpaths = tests
|
||||||
|
pythonpath = src
|
||||||
python_files = test_*.py
|
python_files = test_*.py
|
||||||
python_classes = Test*
|
python_classes = Test*
|
||||||
python_functions = test_*
|
python_functions = test_*
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ family tree.
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
from individual import Individual
|
from individual import Individual
|
||||||
|
|
||||||
@@ -85,7 +86,11 @@ class IndexGenerator:
|
|||||||
|
|
||||||
# Format life span
|
# Format life span
|
||||||
if birth_info["year"] or death_info["date"]:
|
if birth_info["year"] or death_info["date"]:
|
||||||
death_year = death_info["date"][:4] if death_info["date"] else ""
|
death_year = ""
|
||||||
|
if death_info["date"]:
|
||||||
|
match = re.search(r"(\d{4})\b", death_info["date"])
|
||||||
|
if match:
|
||||||
|
death_year = match.group(1)
|
||||||
life_span = f" ({birth_info['year']}-{death_year})"
|
life_span = f" ({birth_info['year']}-{death_year})"
|
||||||
else:
|
else:
|
||||||
life_span = ""
|
life_span = ""
|
||||||
|
|||||||
@@ -9,12 +9,8 @@ This module tests GEDCOM file parsing functionality including:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add src to path for imports
|
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent / 'src'))
|
|
||||||
|
|
||||||
from gedcom_parser import GedcomParser
|
from gedcom_parser import GedcomParser
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,8 @@ This module tests index file generation including:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add src to path for imports
|
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent / 'src'))
|
|
||||||
|
|
||||||
from gedcom_parser import GedcomParser
|
from gedcom_parser import GedcomParser
|
||||||
from individual import Individual
|
from individual import Individual
|
||||||
from index_generator import IndexGenerator
|
from index_generator import IndexGenerator
|
||||||
@@ -269,9 +265,8 @@ class TestLifeSpanFormatting:
|
|||||||
index_path = generator.generate_index(individuals_with_dates)
|
index_path = generator.generate_index(individuals_with_dates)
|
||||||
content = index_path.read_text()
|
content = index_path.read_text()
|
||||||
|
|
||||||
# Death date extraction gets first 4 chars: "15 J" from "15 JUN 2020"
|
# Death date "15 JUN 2020" should extract year "2020"
|
||||||
# This is actually a bug in the code but we test actual behavior
|
assert '(1950-2020)' in content
|
||||||
assert '(1950-' in content # Just verify birth year is present
|
|
||||||
|
|
||||||
def test_life_span_with_only_birth(self, temp_dir, output_dir):
|
def test_life_span_with_only_birth(self, temp_dir, output_dir):
|
||||||
"""Test life span with only birth date."""
|
"""Test life span with only birth date."""
|
||||||
@@ -328,6 +323,36 @@ class TestLifeSpanFormatting:
|
|||||||
# Line should end with WikiLink, not life span
|
# Line should end with WikiLink, not life span
|
||||||
assert not lines[0].strip().endswith(')')
|
assert not lines[0].strip().endswith(')')
|
||||||
|
|
||||||
|
def test_death_year_extraction_from_day_first_format(self, temp_dir, output_dir):
|
||||||
|
"""Test that death year is correctly extracted when date starts with day."""
|
||||||
|
gedcom_content = """0 HEAD
|
||||||
|
1 SOUR TestApp
|
||||||
|
1 GEDC
|
||||||
|
2 VERS 5.5.1
|
||||||
|
1 CHAR UTF-8
|
||||||
|
0 @I1@ INDI
|
||||||
|
1 NAME Test /Person/
|
||||||
|
1 BIRT
|
||||||
|
2 DATE 1950
|
||||||
|
1 DEAT
|
||||||
|
2 DATE 15 JUN 2020
|
||||||
|
0 TRLR
|
||||||
|
"""
|
||||||
|
temp_file = temp_dir / "day_first.ged"
|
||||||
|
temp_file.write_text(gedcom_content, encoding='utf-8')
|
||||||
|
|
||||||
|
parser = GedcomParser(temp_file)
|
||||||
|
elements = parser.get_individuals()
|
||||||
|
individuals = [Individual(elem, parser) for elem in elements]
|
||||||
|
|
||||||
|
generator = IndexGenerator(output_dir)
|
||||||
|
index_path = generator.generate_index(individuals)
|
||||||
|
content = index_path.read_text()
|
||||||
|
|
||||||
|
# Should show (1950-2020), not (1950-15 J)
|
||||||
|
assert '(1950-2020)' in content
|
||||||
|
assert '15 J' not in content
|
||||||
|
|
||||||
|
|
||||||
class TestIndexStatistics:
|
class TestIndexStatistics:
|
||||||
"""Tests for index statistics and metadata."""
|
"""Tests for index statistics and metadata."""
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ This module tests individual person data extraction including:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add src to path for imports
|
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent / 'src'))
|
|
||||||
|
|
||||||
from gedcom_parser import GedcomParser
|
from gedcom_parser import GedcomParser
|
||||||
from individual import Individual
|
from individual import Individual
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,11 @@ This module tests the command-line interface and main conversion workflow includ
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
# Add src to path for imports
|
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent / 'src'))
|
|
||||||
|
|
||||||
import main
|
import main
|
||||||
from main import (
|
from main import (
|
||||||
setup_logging,
|
setup_logging,
|
||||||
|
|||||||
@@ -10,12 +10,8 @@ This module tests Obsidian markdown note generation including:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add src to path for imports
|
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent / 'src'))
|
|
||||||
|
|
||||||
from gedcom_parser import GedcomParser
|
from gedcom_parser import GedcomParser
|
||||||
from individual import Individual
|
from individual import Individual
|
||||||
from markdown_generator import MarkdownGenerator
|
from markdown_generator import MarkdownGenerator
|
||||||
|
|||||||
Reference in new issue
Block a user