def test_index_update(): ''' :return: Test: index creation from legacy form update() function update of Index, like what happens on the frontend, doesn't whack hidden attrs ''' ti = "Test Iu" i = model.Index({ "title": ti, "heTitle": "כבכב", "titleVariants": [ti], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Musar"], "lengths": [50, 501] }).save() i = model.Index().load({"title": ti}) assert "Musar" in i.categories assert i.nodes.lengths == [50, 501] i = model.Index().update({"title": ti}, { "title": ti, "heTitle": "כבכב", "titleVariants": [ti], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Jewish Thought"] }) i = model.Index().load({"title": ti}) assert "Musar" not in i.categories assert "Jewish Thought" in i.categories assert i.nodes.lengths == [50, 501] model.IndexSet({"title": ti}).delete()
def test_index_delete(): #Simple Text ti = "Test Del" i = model.Index({ "title": ti, "heTitle": "כבכב", "titleVariants": [ti], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Musar"], "lengths": [50, 501] }).save() new_version1 = model.Version({ "chapter": i.nodes.create_skeleton(), "versionTitle": "Version 1 TEST", "versionSource": "blabla", "language": "he", "title": i.title }) new_version1.chapter = [[''], [''], ["לה לה לה לא חשוב על מה"]] new_version1.save() new_version2 = model.Version({ "chapter": i.nodes.create_skeleton(), "versionTitle": "Version 2 TEST", "versionSource": "blabla", "language": "en", "title": i.title }) new_version2.chapter = [[], ["Hello goodbye bla bla blah"], []] new_version2.save() i.delete() assert model.Index().load({'title': ti}) is None assert model.VersionSet({'title': ti}).count() == 0
def test_index_add_delete(self): #test that the index new_index = model.Index({ "title": "New Toc Test", "heTitle": u"פםפם", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Philosophy"] }) verify_existence_across_tocs(new_index.title, None) new_index.save() verify_existence_across_tocs( new_index.title, expected_toc_location=new_index.categories) new_index.delete() verify_existence_across_tocs(new_index.title, None) new_other_index = model.Index({ "title": "Another New Toc Test", "heTitle": u"פםפם", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Law"] }) verify_existence_across_tocs(new_other_index.title, None) new_other_index.save() verify_existence_across_tocs(new_other_index.title, expected_toc_location=['Other'] + new_other_index.categories) new_other_index.delete() verify_existence_across_tocs(new_other_index.title, None) new_commentary_index = model.Index({ "title": "Harchev Davar on Joshua", "heTitle": u"הרחב דבר על יהושוע", "dependence": "Commentary", "base_text_titles": ["Joshua"], "collective_title": "Harchev Davar", "sectionNames": ["Chapter", "Paragraph", "Comment"], "categories": ["Tanakh", "Commentary", "Harchev Davar", "Prophets"] }) verify_existence_across_tocs(new_commentary_index.title, None) new_commentary_index.save() verify_title_existence_in_toc( new_commentary_index.title, expected_toc_location=new_commentary_index.categories, toc=self.toc) verify_title_existence_in_toc(new_commentary_index.title, expected_toc_location=[ "Tanakh Commentaries", "Harchev Davar", "Prophets" ], toc=self.search_toc) new_commentary_index.delete() verify_existence_across_tocs(new_commentary_index.title, None)
def test_index_delete(): #Simple Text ti = "Test Del" model.IndexSet({"title": ti}).delete() model.VersionSet({"title": ti}).delete() i = model.Index({ "title": ti, "heTitle": u"כבכב", "titleVariants": [ti], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Musar"], "lengths": [50, 501] }).save() new_version1 = model.Version( { "chapter": i.nodes.create_skeleton(), "versionTitle": "Version 1 TEST", "versionSource": "blabla", "language": "he", "title": i.title } ) new_version1.chapter = [[u''],[u''],[u"לה לה לה לא חשוב על מה"]] new_version1.save() new_version2 = model.Version( { "chapter": i.nodes.create_skeleton(), "versionTitle": "Version 2 TEST", "versionSource": "blabla", "language": "en", "title": i.title } ) new_version2.chapter = [[],["Hello goodbye bla bla blah"],[]] new_version2.save() i.delete() assert model.Index().load({'title': ti}) is None assert model.VersionSet({'title':ti}).count() == 0 #Commentator from sefaria.helper.text import create_commentator_and_commentary_version commentator_name = "Commentator Del" he_commentator_name = u"פרשנדנן" base_book = 'Genesis' base_book2 = 'Pesach Haggadah' model.IndexSet({"title": commentator_name}).delete() model.VersionSet({"title": commentator_name + " on " + base_book}).delete() model.VersionSet({"title": commentator_name + " on " + base_book2}).delete() create_commentator_and_commentary_version(commentator_name, base_book, 'he', 'test', 'test', he_commentator_name) create_commentator_and_commentary_version(commentator_name, base_book2, 'he', 'test', 'test', he_commentator_name) ci = model.Index().load({'title': commentator_name}).delete() assert model.Index().load({'title': commentator_name}) is None assert model.VersionSet({'title':{'$regex': commentator_name}}).count() == 0
def test_dup2_index_save(): title = 'Test Commentator Name' model.IndexSet({"title": title}).delete() d = { "title": title, "heTitle": u"פרשן ב", "titleVariants": [title], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Commentary"], "lengths": [50, 501] } idx = model.Index(d) idx.save() assert model.IndexSet({"title": title}).count() == 1 try: d2 = { "categories" : [ "Liturgy" ], "title" : title, "schema" : { "titles" : [ { "lang" : "en", "text" : title, "primary" : True }, { "lang" : "he", "text" : "פרשן", "primary" : True } ], "nodeType" : "JaggedArrayNode", "depth" : 2, "sectionNames" : [ "Section", "Line" ], "addressTypes" : [ "Integer", "Integer" ], "key": title }, } idx2 = model.Index(d2).save() except: pass assert model.IndexSet({"title": title}).count() == 1
def test_index_attr_change(self): indx = model.Index().load({"title": "Or HaChaim on Genesis"}) verify_title_existence_in_toc(indx.title, expected_toc_location=['Tanakh', 'Commentary', 'Or HaChaim', 'Torah'], toc=model.library.get_toc()) verify_title_existence_in_toc(indx.title, expected_toc_location=['Tanakh Commentaries', 'Or HaChaim', 'Torah'], toc=model.library.get_search_filter_toc()) indx.nodes.add_title("Or HaChaim HaKadosh", "en") indx.save() verify_title_existence_in_toc(indx.title, expected_toc_location=['Tanakh', 'Commentary', 'Or HaChaim', 'Torah']) verify_title_existence_in_toc(indx.title, expected_toc_location=['Tanakh Commentaries', 'Or HaChaim', 'Torah'], toc=model.library.get_search_filter_toc()) indx2 = model.Index().load({"title": "Sefer Kuzari"}) #Was Tanya, but Tanya has a hebrew title clash problem, momentarily. verify_existence_across_tocs(indx2.title, expected_toc_location=indx2.categories) indx2.nodes.add_title("Kuzari Test", "en") indx2.save() verify_existence_across_tocs(indx2.title, expected_toc_location=indx2.categories)
def test_index_attr_change(): indx = model.Index().load({"title": "Or HaChaim"}) verify_title_existence_in_toc(indx.title, None) verify_title_existence_in_toc(indx.title + ' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) indx.titleVariants.append("Or HaChaim HaKadosh") indx.save() verify_title_existence_in_toc(indx.title, None) verify_title_existence_in_toc(indx.title + ' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) indx2 = model.Index().load({"title": "Tanya"}) verify_title_existence_in_toc(indx2.title, indx2.categories) indx2.titleVariants.append("Tanya Test") indx2.save() verify_title_existence_in_toc(indx2.title, indx2.categories)
def test_index_title_setter(): title = 'Test Index Name' d = { "categories" : [ "Liturgy" ], "title" : title, "schema" : { "titles" : [ { "lang" : "en", "text" : title, "primary" : True }, { "lang" : "he", "text" : "דוגמא", "primary" : True } ], "nodeType" : "JaggedArrayNode", "depth" : 2, "sectionNames" : [ "Section", "Line" ], "addressTypes" : [ "Integer", "Integer" ], "key": title }, } idx = model.Index(d) assert idx.title == title assert idx.nodes.key == title assert idx.nodes.primary_title("en") == title assert getattr(idx, 'title') == title idx.save() new_title = "Changed Test Index" new_heb_title = "דוגמא אחרי שינוי" idx.title = new_title assert idx.title == new_title assert idx.nodes.key == new_title assert idx.nodes.primary_title("en") == new_title assert getattr(idx, 'title') == new_title idx.set_title(new_heb_title, 'he') assert idx.nodes.primary_title('he') == new_heb_title third_title = "Third Attempt" setattr(idx, 'title', third_title) assert idx.title == third_title assert idx.nodes.key == third_title assert idx.nodes.primary_title("en") == third_title assert getattr(idx, 'title') == third_title idx.delete()
def test_commentary_index_title_change(self): old_title = 'Sforno' new_title = 'Sforno New' i = model.Index().load({"title": old_title}) verify_title_existence_in_toc(old_title, None) verify_title_existence_in_toc( old_title + ' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) i.title = new_title i.save() #old title not there verify_title_existence_in_toc(old_title, None) #new one not either since it's just a commentator name verify_title_existence_in_toc(new_title, None) verify_title_existence_in_toc( new_title + ' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) #do testing: make sure new title is in the old place in the toc and that the old title is removed i.title = old_title i.save() #old title not there anymore verify_title_existence_in_toc(new_title, None) #new one in it's place verify_title_existence_in_toc(old_title, None) verify_title_existence_in_toc( old_title + ' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis'])
def test_index_name_change(): #Simple Text tests = [ (u"Exodus", u"Movement of Ja People"), # Simple Text (u"Rashi", u"The Vintner") # Commentator ] for old, new in tests: for cnt in dep_counts(new).values(): assert cnt == 0 old_counts = dep_counts(old) index = model.Index().load({"title": old}) old_index = deepcopy(index) #new_in_alt = new in index.titleVariants index.title = new index.save() assert old_counts == dep_counts(new) index.title = old #if not new_in_alt: if getattr(index, "titleVariants", None): index.titleVariants.remove(new) index.save() #assert old_index == index #needs redo of titling, above, i suspect assert old_counts == dep_counts(old) for cnt in dep_counts(new).values(): assert cnt == 0
def test_index_attr_change(self): indx = model.Index().load({"title": "Or HaChaim"}) verify_title_existence_in_toc(indx.title, None) verify_title_existence_in_toc(indx.title+' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) indx.titleVariants.append("Or HaChaim HaKadosh") #indx.nodes.add_title("Or HaChaim HaKadosh", "en") indx.save() verify_title_existence_in_toc(indx.title, None) verify_title_existence_in_toc(indx.title+' on Genesis', ['Tanach', 'Commentary', 'Torah', 'Genesis']) indx2 = model.Index().load({"title": "Sefer Kuzari"}) #Was Tanya, but Tanya has a hebrew title clash problem, momentarily. verify_title_existence_in_toc(indx2.title, indx2.categories) #indx2.titleVariants.append("Tanya Test") indx2.nodes.add_title("Kuzari Test", "en") indx2.save() verify_title_existence_in_toc(indx2.title, indx2.categories)
def test_invalid_index_save_no_category(): title = 'Bartenura (The Next Generation)' model.IndexSet({"title": title}).delete() d = { "categories": ["Mishnah", "Commentary", "Bartenura", "Gargamel"], "title": title, "schema": { "titles": [{ "lang": "en", "text": title, "primary": True }, { "lang": "he", "text": "פרשן", "primary": True }], "nodeType": "JaggedArrayNode", "depth": 2, "sectionNames": ["Section", "Line"], "addressTypes": ["Integer", "Integer"], "key": title }, } idx = model.Index(d) with pytest.raises(InputError) as e_info: idx.save() assert "You must create category Mishnah/Commentary/Bartenura/Gargamel before adding texts to it." in str( e_info.value) assert model.IndexSet({"title": title}).count() == 0
def test_index_title_change(self): try: i = model.library.get_index("The Likutei Moharan") if i: i.delete() except BookNameError: pass old_title = 'Likutei Moharan' new_title = 'The Likutei Moharan' toc_location = ['Chasidut'] old_toc_path = get_all_toc_locations(old_title)[0] assert toc_path_to_string(old_toc_path) == toc_path_to_string( toc_location) i = model.Index().load({"title": old_title}) i.title = new_title i.save() #old title not there anymore verify_title_existence_in_toc(old_title, None) #new one in it's place verify_title_existence_in_toc(new_title, old_toc_path) #do testing: make sure new title is in the old place in the toc and that the old title is removed i.title = old_title i.save() #old title not there anymore verify_title_existence_in_toc(new_title, None) #new one in it's place verify_title_existence_in_toc(old_title, old_toc_path)
def verify_text_node_integrity(self, node): global text_titles lang_keys = get_lang_keys() assert set(node.keys()) >= {'title', 'heTitle', 'sparseness', 'categories'} assert (node['title'] in text_titles) or (not model.Index().load({"title": node['title']}).is_commentary()), node['title'] assert 'category' not in node assert isinstance(node['sparseness'], int)
def test_invalid_index_save_no_hebrew_collective_title(): title = 'Bartenura (The Next Generation)' model.IndexSet({"title": title}).delete() d = { "categories": ["Mishnah", "Rishonim on Mishnah", "Bartenura"], "collective_title": 'Gargamel', "title": title, "schema": { "titles": [{ "lang": "en", "text": title, "primary": True }, { "lang": "he", "text": "פרשן", "primary": True }], "nodeType": "JaggedArrayNode", "depth": 2, "sectionNames": ["Section", "Line"], "addressTypes": ["Integer", "Integer"], "key": title }, } idx = model.Index(d) with pytest.raises(InputError) as e_info: idx.save() assert "You must add a hebrew translation Term for any new Collective Title: Gargamel." in str( e_info.value) assert model.IndexSet({"title": title}).count() == 0
def test_invalid_index_save_no_existing_base_text(): title = 'Bartenura (The Next Generation)' model.IndexSet({"title": title}).delete() d = { "categories": ["Mishnah", "Commentary", "Bartenura", "Seder Zeraim"], "base_text_titles": ["Gargamel"], "title": title, "schema": { "titles": [{ "lang": "en", "text": title, "primary": True }, { "lang": "he", "text": "פרשן", "primary": True }], "nodeType": "JaggedArrayNode", "depth": 2, "sectionNames": ["Section", "Line"], "addressTypes": ["Integer", "Integer"], "key": title }, } idx = model.Index(d) with pytest.raises(InputError) as e_info: idx.save() assert "Base Text Titles must point to existing texts in the system." in str( e_info.value) assert model.IndexSet({"title": title}).count() == 0
def test_index_name_change(): #Simple Text tests = [ ("The Book of Maccabees I", "Movement of Ja People"), # Simple Text # (u"Rashi", u"The Vintner") # Commentator Invalid after commentary refactor? ] for old, new in tests: index = model.Index().load({"title": old}) # Make sure that the test isn't passing just because we've been comparing 0 to 0 assert all([cnt > 0 for cnt in dep_counts(old, index)]) for cnt in list(dep_counts(new, index).values()): assert cnt == 0 old_counts = dep_counts(old, index) old_index = deepcopy(index) #new_in_alt = new in index.titleVariants index.title = new index.save() assert old_counts == dep_counts(new, index) index.title = old #if not new_in_alt: if getattr(index, "titleVariants", None): index.titleVariants.remove(new) index.save() #assert old_index == index #needs redo of titling, above, i suspect assert old_counts == dep_counts(old, index) for cnt in list(dep_counts(new, index).values()): assert cnt == 0
def test_index_add_delete(self): #test that the index new_index = model.Index({ "title": "New Toc Test", "heTitle": u"פםפם", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Philosophy"] }) verify_title_existence_in_toc(new_index.title, None) new_index.save() verify_title_existence_in_toc(new_index.title, new_index.categories) new_index.delete() verify_title_existence_in_toc(new_index.title, None) #commentator alone should not be in the toc new_commentator = model.Index({ "title": "New Toc Commentator Test", "heTitle": u"םפםפכ", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Commentary"] }) new_commentator.save() verify_title_existence_in_toc(new_commentator.title, None) new_commentator.delete() verify_title_existence_in_toc(new_commentator.title, None) new_other_index = model.Index({ "title": "New Toc Test", "heTitle": u"פםפם", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Testing"] }) verify_title_existence_in_toc(new_other_index.title, None) new_other_index.save() verify_title_existence_in_toc(new_other_index.title, ['Other'] + new_other_index.categories) new_other_index.delete() verify_title_existence_in_toc(new_other_index.title, None)
def verify_text_node_integrity(node): global text_titles lang_keys = get_lang_keys() #do we need to assert that the title is not equal to any category name? assert set(node.keys()) >= { u'title', 'availableCounts', u'sectionNames', 'isSparse', 'percentAvailable', u'titleVariants', u'categories', 'textDepth' }, node.keys() assert (node['title'] in text_titles) or (not model.Index().load({ "title": node['title'] }).is_commentary()), node['title'] assert 'category' not in node assert isinstance(node['availableCounts'], dict) assert set(node['availableCounts'].keys()) == lang_keys assert isinstance(node['percentAvailable'], dict) assert set(node['percentAvailable'].keys()) == lang_keys
def test_index_title_change(): old_title = 'Tanya' new_title = 'The Tanya' toc_location = ['Chasidut'] old_toc_path = get_all_toc_locations(old_title)[0] assert toc_path_to_string(old_toc_path) == toc_path_to_string(toc_location) i = model.Index().load({"title": old_title}) i.title = new_title i.save() #old title not there anymore verify_title_existence_in_toc(old_title, None) #new one in it's place verify_title_existence_in_toc(new_title, old_toc_path) #do testing: make sure new title is in the old place in the toc and that the old title is removed i.title = old_title i.save() #old title not there anymore verify_title_existence_in_toc(new_title, None) #new one in it's place verify_title_existence_in_toc(old_title, old_toc_path)
def test_new_index_title_change(self): new_index = model.Index({ "title": "New Toc Title Test", "heTitle": u"פםעעפם", "titleVariants": [], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Philosophy"] }) verify_title_existence_in_toc(new_index.title, None) new_index.save() verify_title_existence_in_toc(new_index.title, new_index.categories) # title change old_title = new_index.title new_title = "Bob is your Uncle" new_index.title = new_title new_index.save() verify_title_existence_in_toc(old_title, None) verify_title_existence_in_toc(new_title, new_index.categories) new_index.delete() verify_title_existence_in_toc(new_title, None) verify_title_existence_in_toc(old_title, None)
def setup_class(cls): cls.simpleIndex = model.Index({ "title": cls.simpleIndexTitle, "heTitle": "בלה1", "titleVariants": [cls.simpleIndexTitle], "sectionNames": ["Chapter", "Paragraph"], "categories": ["Musar"], "lengths": [50, 501] }).save() cls.simpleVersion = model.Version({ "chapter": cls.simpleIndex.nodes.create_skeleton(), "versionTitle": "Version 1 TEST", "versionSource": "blabla", "language": "he", "title": cls.simpleIndexTitle }) cls.simpleVersion.chapter = [['1'], ['2'], ["original text", "2nd"]] cls.simpleVersion.save() cls.complexIndex = model.Index({ "title": cls.complexIndexTitle, "heTitle": "2בלה", "titleVariants": [cls.complexIndexTitle], "schema": { "nodes": [{ "nodes": [{ "nodeType": "JaggedArrayNode", "depth": 2, "sectionNames": ["Chapter", "Paragraph"], "addressTypes": ["Integer", "Integer"], "titles": [{ "text": "Node 2", "lang": "en", "primary": True }, { "text": "Node 2 he", "lang": "he", "primary": True }], "key": "Node 2" }], "titles": [{ "text": "Node 1", "lang": "en", "primary": True }, { "text": "Node 1 he", "lang": "he", "primary": True }], "key": "Node 1" }, { "nodeType": "JaggedArrayNode", "depth": 1, "sectionNames": ["Paragraph"], "addressTypes": ["Integer"], "titles": [{ "text": "Node 3", "lang": "en", "primary": True }, { "text": "Node 3 he", "lang": "he", "primary": True }], "key": "Node 3" }], "titles": [{ "text": cls.complexIndexTitle, "lang": "en", "primary": True }, { "text": cls.complexIndexTitle + "he", "lang": "he", "primary": True }], "key": cls.complexIndexTitle }, "categories": ["Musar"] }).save() cls.complexVersion = model.Version({ "chapter": cls.complexIndex.nodes.create_skeleton(), "versionTitle": "Version 2 TEST", "versionSource": "blabla", "language": "en", "title": cls.complexIndexTitle }) cls.complexVersion.chapter = { "Node 1": { "Node 2": [['yo'], ['', 'blah'], ["original text", "2nd"]] }, "Node 3": ['1', '2', '3', '4'] } cls.complexVersion.save()
def test_index_title_setter(): title = 'Test Index Name' he_title = "דוגמא" d = { "categories": ["Liturgy"], "title": title, "schema": { "titles": [{ "lang": "en", "text": title, "primary": True }, { "lang": "he", "text": he_title, "primary": True }], "nodeType": "JaggedArrayNode", "depth": 2, "sectionNames": ["Section", "Line"], "addressTypes": ["Integer", "Integer"], "key": title }, } idx = model.Index(d) assert idx.title == title assert idx.nodes.key == title assert idx.nodes.primary_title("en") == title assert getattr(idx, 'title') == title idx.save() new_title = "Changed Test Index" new_heb_title = "דוגמא אחרי שינוי" idx.title = new_title assert idx.title == new_title assert idx.nodes.key == new_title assert idx.nodes.primary_title("en") == new_title assert getattr(idx, 'title') == new_title idx.set_title(new_heb_title, 'he') assert idx.nodes.primary_title('he') == new_heb_title third_title = "Third Attempt" setattr(idx, 'title', third_title) assert idx.title == third_title assert idx.nodes.key == third_title assert idx.nodes.primary_title("en") == third_title assert getattr(idx, 'title') == third_title idx.save() # make sure all caches pointing to this index are cleaned up for t in [("en", title), ("en", new_title), ("he", he_title), ("en", new_heb_title)]: assert t[1] not in model.library._index_title_maps[t[0]] assert title not in model.library._index_map assert new_title not in model.library._index_map idx.delete() assert title not in model.library._index_map assert new_title not in model.library._index_map assert third_title not in model.library._index_map for t in [("en", title), ("en", new_title), ("en", third_title), ("he", he_title), ("en", new_heb_title)]: assert t[1] not in model.library._index_title_maps[t[0]]
import sefaria.model as model from sefaria.system.database import db from sefaria.clean import remove_old_counts # Move the history books model.IndexSet({"categories":"History"}).update({"categories": [u'Apocrypha']}) anaBekhoach = model.Index().load({'title': 'Ana BeKhoach'}) anaBekhoach.categories = [u'Liturgy',u'Piyutim'] #why doesn't update() work on an instance? anaBekhoach.save() model.IndexSet({"title":{"$regex": "Rabbah?"}}).update({"categories": ['Midrash', 'Aggadic Midrash', 'Midrash Rabbah']}) #this one should not have been updated. model.Index().update({'title': 'Tanna Debei Eliyahu Rabbah'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.IndexSet({'title': {"$regex" : 'Ein Yaakov'}}).update({'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Midrash Tanchuma'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Legends of the Jews'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Midrash Mishlei'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Pirkei Derabi Eliezer'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Midrash on Proverbs'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': "Midrash B'not Zelophehad"}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Midrash Tehilim'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Pesikta de rav kahana'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'The Fathers according to Rabbi Nathan'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Yalkut Shimoni'}, {'categories': ['Midrash', 'Aggadic Midrash']}) model.Index().update({'title': 'Sifra'}, {'categories': ['Midrash', 'Halachic Midrash']})
def test_index_methods(): assert model.Index().load({"title": "Rashi"}).is_commentary() assert not model.Index().load({"title": "Exodus"}).is_commentary()