def test_get_default_category_name_caching(tag_category_factory): category1 = tag_category_factory() category2 = tag_category_factory() db.session.add_all([category1, category2]) db.session.flush() tag_categories.get_default_category_name() db.session.delete(category1) db.session.flush() assert tag_categories.get_default_category_name() == category1.name cache.purge() assert tag_categories.get_default_category_name() == category2.name
def test_get_default_category_name(tag_category_factory): category1 = tag_category_factory() category2 = tag_category_factory(default=True) db.session.add_all([category1, category2]) db.session.flush() assert tag_categories.get_default_category_name() == category2.name category2.default = False db.session.flush() cache.purge() assert tag_categories.get_default_category_name() == category1.name db.session.query(db.TagCategory).delete() cache.purge() assert tag_categories.get_default_category_name() is None
def test_get_default_category_name(tag_category_factory): category1 = tag_category_factory() category2 = tag_category_factory(default=True) db.session.add_all([category1, category2]) db.session.flush() assert tag_categories.get_default_category_name() == category2.name category2.default = False db.session.flush() cache.purge() assert tag_categories.get_default_category_name() == category1.name db.session.query(model.TagCategory).delete() cache.purge() with pytest.raises(tag_categories.TagCategoryNotFoundError): tag_categories.get_default_category_name()
def purge_cache(): cache.purge()
def process_request(ctx: rest.Context) -> None: if ctx.method != "GET": cache.purge()
def process_request(ctx): if ctx.method != 'GET': cache.purge()
def process_request(ctx: rest.Context) -> None: if ctx.method != 'GET': cache.purge()