import sys from app.arabic_nlp import is_root_match from app.hadith_utils import highlight_narrators from app.synonyms import expand_synonyms def test_root_match(): # Root R-H-M (رحم) root = "رحم" assert is_root_match("الرحيم", root) == True assert is_root_match("الرحمن", root) == True assert is_root_match("يرحمكم", root) == True assert is_root_match("صبر", root) == False print("✅ Root match test passed") def test_highlighting(): text = "حَدَّثَنَا عَبْدُ اللَّهِ بْنُ نُمَيْرٍ، عَنْ قَيْسٍ" highlighted = highlight_narrators(text) assert "**حَدَّثَنَا**" in highlighted assert "**عَنْ**" in highlighted print("✅ Highlighting test passed") def test_synonyms(): keywords = ["patience"] expanded = expand_synonyms(keywords) assert "sabr" in expanded assert "صبر" in expanded print("✅ Synonyms test passed") if __name__ == "__main__": try: test_root_match() test_highlighting() test_synonyms() print("All tests passed!") except Exception as e: print(f"❌ Test failed: {e}") sys.exit(1)