Skip to content

Commit

Permalink
Merge pull request #1964 from Sefaria/fix-ibn-ezra-test
Browse files Browse the repository at this point in the history
test(library): fix failing test due to title change of Ibn Ezra.
  • Loading branch information
nsantacruz committed Jul 14, 2024
2 parents b5a63aa + 3730415 commit 51f948d
Showing 1 changed file with 49 additions and 43 deletions.
92 changes: 49 additions & 43 deletions sefaria/model/tests/text_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@ def test_merge():


def test_text_helpers():
res = model.library.get_dependant_indices()
assert 'Rashbam on Genesis' in res
assert 'Rashi on Bava Batra' in res
assert 'Bartenura on Mishnah Oholot' in res
assert 'Onkelos Leviticus' in res
assert 'Chizkuni' in res
assert 'Akeidat Yitzchak' not in res
assert 'Berakhot' not in res

res = model.library.get_indices_by_collective_title("Rashi")
assert 'Rashi on Bava Batra' in res
assert 'Rashi on Genesis' in res
Expand All @@ -346,46 +337,61 @@ def test_text_helpers():
assert 'Bartenura on Mishnah Oholot' in res
assert 'Rashbam on Genesis' not in res

res = model.library.get_dependant_indices(book_title="Exodus")
assert 'Ibn Ezra on Exodus' in res
assert 'Ramban on Exodus' in res
assert 'Meshekh Chokhmah' in res
assert 'Abarbanel on Torah' in res
assert 'Targum Jonathan on Exodus' in res
assert 'Onkelos Exodus' in res
assert 'Harchev Davar on Exodus' in res

assert 'Exodus' not in res
assert 'Rashi on Genesis' not in res

res = model.library.get_dependant_indices(book_title="Exodus", dependence_type='Commentary')
assert 'Ibn Ezra on Exodus' in res
assert 'Ramban on Exodus' in res
assert 'Meshekh Chokhmah' in res
assert 'Abarbanel on Torah' in res
assert 'Harchev Davar on Exodus' in res

assert 'Targum Jonathan on Exodus' not in res
assert 'Onkelos Exodus' not in res
assert 'Exodus' not in res
assert 'Rashi on Genesis' not in res

res = model.library.get_dependant_indices(book_title="Exodus", dependence_type='Commentary', structure_match=True)
assert 'Ibn Ezra on Exodus' in res
assert 'Ramban on Exodus' in res

assert 'Harchev Davar on Exodus' not in res
assert 'Meshekh Chokhmah' not in res
assert 'Abarbanel on Torah' not in res
assert 'Exodus' not in res
assert 'Rashi on Genesis' not in res

cats = model.library.get_text_categories()
assert 'Tanakh' in cats
assert 'Torah' in cats
assert 'Prophets' in cats
assert 'Commentary' in cats

@pytest.mark.parametrize(('book_title', 'dependence_type', 'structure_match', 'expected_titles', 'not_expected_titles'), [
[None, None, False, [
'Rashbam on Genesis',
'Rashi on Bava Batra',
'Bartenura on Mishnah Oholot',
'Onkelos Leviticus',
'Chizkuni',
], [
'Akeidat Yitzchak',
'Berakhot']
],
['Exodus', None, False, ['Ibn Ezra on Exodus; Perush HaArokh',
'Ramban on Exodus',
'Abarbanel on Torah',
'Meshekh Chokhmah',
'Targum Jonathan on Exodus',
'Onkelos Exodus',
'Harchev Davar on Exodus'
], ['Exodus',
'Rashi on Genesis']
],
['Exodus', 'Commentary', False, ['Ibn Ezra on Exodus; Perush HaArokh',
'Ramban on Exodus',
'Abarbanel on Torah',
'Meshekh Chokhmah',
'Harchev Davar on Exodus'
], ['Targum Jonathan on Exodus',
'Onkelos Exodus',
'Exodus',
'Rashi on Genesis']
],
['Exodus', 'Commentary', True, ['Ibn Ezra on Exodus; Perush HaArokh',
'Ramban on Exodus'
], ['Abarbanel on Torah',
'Meshekh Chokhmah',
'Targum Jonathan on Exodus',
'Onkelos Exodus',
'Harchev Davar on Exodus',
'Exodus',
'Rashi on Genesis']
],
])
def test_get_dependent_indices(book_title, dependence_type, structure_match, expected_titles, not_expected_titles):
res = model.library.get_dependant_indices(book_title=book_title, dependence_type=dependence_type, structure_match=structure_match)
for title in expected_titles:
assert title in res
for title in not_expected_titles:
assert title not in res


def test_index_update():
'''
Expand Down

0 comments on commit 51f948d

Please sign in to comment.