def reset_index_cache_for_text(request, title): index = model.library.get_index(title) model.library.refresh_index_record_in_cache(index) scache.delete_cache_elem(scache.generate_text_toc_cache_key(title)) if USE_VARNISH: invalidate_title(title) return HttpResponseRedirect("/%s?m=Cache-Reset" % model.Ref(title).url())
def reset_ref(request, tref): """ resets cache, versionstate, toc, varnish, & book TOC template :param tref: :return: """ oref = model.Ref(tref) if oref.is_book_level(): model.library.refresh_index_record_in_cache(oref.index) vs = model.VersionState(index=oref.index) vs.refresh() model.library.update_index_in_toc(oref.index) scache.delete_cache_elem(scache.generate_text_toc_cache_key(oref.index.title)) if USE_VARNISH: invalidate_index(oref.index) invalidate_counts(oref.index) invalidate_ref(oref) return HttpResponseRedirect("/{}?m=Reset-Index".format(oref.url())) elif USE_VARNISH: invalidate_ref(oref) return HttpResponseRedirect("/{}?m=Reset-Ref".format(oref.url())) else: return HttpResponseRedirect("/?m=Nothing-to-Reset")
import sefaria.summaries as s import sefaria.model as model import sefaria.system.cache as scache from sefaria.utils.testing_utils import * #create, update, delete, change categories # test that old title goes away on index title change (regular + commentary) # test that no commentator is added # no wandering commentaries """ SOME SETUP """ text_titles = model.VersionSet({}).distinct('title') s.update_table_of_contents() scache.delete_cache_elem('toc_cache') """ THE TESTS """ class Test_Toc(object): def test_toc_integrity(self): toc = s.get_toc() self.recur_toc_integrity(toc) def recur_toc_integrity(self, toc, depth=0): for toc_elem in toc: if 'category' in toc_elem: #verify proper category node (including that it doesnt have a title attr)
import sefaria.model as model import sefaria.system.cache as scache from sefaria.system.exceptions import BookNameError from sefaria.utils.testing_utils import * # create, update, delete, change categories # test that old title goes away on index title change (regular + commentary) # test that no commentator is added # no wandering commentaries """ SOME SETUP """ text_titles = model.VersionSet({}).distinct("title") model.library.rebuild_toc() scache.delete_cache_elem("toc_cache") """ THE TESTS """ class Test_Toc(object): def test_toc_integrity(self): model.library.rebuild_toc() toc = model.library.get_toc() self.recur_toc_integrity(toc) def recur_toc_integrity(self, toc, depth=0): for toc_elem in toc: if "category" in toc_elem: # verify proper category node (including that it doesnt have a title attr)