import os
import sys
import unittest
# Add the parent directory to sys.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from src.gedcom_mcp.gedcom_utils import normalize_string, _get_gedcom_tag_from_event_type, _get_gedcom_tag_from_attribute_type, extract_birth_year, _extract_year_from_genealogy_date, _normalize_genealogy_name, _normalize_genealogy_date, _normalize_genealogy_place, _extract_year_from_date, _matches_criteria
class TestGedcomUtils(unittest.TestCase):
def test_normalize_string(self):
self.assertEqual(normalize_string(" Test String "), "test string")
def test_get_gedcom_tag_from_event_type(self):
self.assertEqual(_get_gedcom_tag_from_event_type("Marriage"), "MARR")
def test_get_gedcom_tag_from_attribute_type(self):
self.assertEqual(_get_gedcom_tag_from_attribute_type("Occupation"), "OCCU")
def test_extract_birth_year(self):
# This function is not in the latest version of gedcom_utils.py
pass
def test_extract_year_from_genealogy_date(self):
self.assertEqual(_extract_year_from_genealogy_date("1 JAN 1970"), 1970)
def test_normalize_genealogy_name(self):
self.assertEqual(_normalize_genealogy_name("John /Smith/"), "John Smith")
def test_normalize_genealogy_date(self):
self.assertEqual(_normalize_genealogy_date("1 JAN 1970"), "1 JAN 1970")
def test_normalize_genealogy_place(self):
self.assertEqual(_normalize_genealogy_place("London, England"), "London, England")
def test_extract_year_from_date(self):
self.assertEqual(_extract_year_from_date("1 JAN 1970"), 1970)
def test_matches_criteria(self):
# This function requires a PersonDetails object, which is complex to create here.
# We will skip this test for now.
pass
if __name__ == '__main__':
unittest.main()