def test_rebuild_chunk(self, apply_async): cache.set(settings.WIKI_REBUILD_TOKEN, True) rebuild_kb() assert not cache.get(settings.WIKI_REBUILD_TOKEN) data = set((1, 2, 4, 5)) assert 'args' in apply_async.call_args[1] eq_(data, set(apply_async.call_args[1]['args'][0]))
def test_external(self): """Make sure rebuild_kb doesn't delete redirects to external URLs.""" doc_pk = revision(content='REDIRECT [http://www.example.com/]', is_approved=True, save=True).document.pk rebuild_kb() assert Document.uncached.filter(pk=doc_pk).exists()
def test_rebuild_chunk(self, apply_async): cache.set(settings.WIKI_REBUILD_TOKEN, True) rebuild_kb() assert not cache.get(settings.WIKI_REBUILD_TOKEN) data = set((1, 2, 4, 5)) assert "args" in apply_async.call_args[1] eq_(data, set(apply_async.call_args[1]["args"][0]))
def test_rebuild_chunk(self, apply_async): cache.set(settings.WIKI_REBUILD_TOKEN, True) rebuild_kb() assert not cache.get(settings.WIKI_REBUILD_TOKEN) assert 'args' in apply_async.call_args[1] # There should be 4 documents with an approved revision eq_(4, len(apply_async.call_args[1]['args'][0]))
def test_delete_redirects(self): """Test that the rebuild deletes redirects that point to deleted documents.""" # Change slug so redirect is created d = Document.objects.get(pk=1) slug = d.slug new_slug = slug + '-1' d.slug = new_slug d.save() # Rebuild kb and make sure redirect is still there rebuild_kb() redirect = Document.objects.get(slug=slug) eq_(d.slug, redirect.redirect_document().slug) # Delete the document, make sure redirect is gone d.delete() rebuild_kb() eq_(0, Document.objects.filter(slug=slug).count())
def test_delete_redirects(self): """Test that the rebuild deletes redirects that point to deleted documents.""" # Change slug so redirect is created: d = revision(is_approved=True, document=document(title="foo", slug="foo", save=True), save=True).document slug = d.slug d.slug = slug + "-1" d.save() # Rebuild kb, and make sure redirect is still there: rebuild_kb() redirect = Document.objects.get(slug=slug) eq_(d.slug, redirect.redirect_document().slug) # Delete the document, and make sure redirect is gone: d.delete() rebuild_kb() eq_(0, Document.objects.filter(slug=slug).count())
def test_delete_redirects(self): """Test that the rebuild deletes redirects that point to deleted documents.""" # Change slug so redirect is created: d = revision(is_approved=True, document=document(title='foo', slug='foo', save=True), save=True).document slug = d.slug d.slug = slug + '-1' d.save() # Rebuild kb, and make sure redirect is still there: rebuild_kb() redirect = Document.objects.get(slug=slug) eq_(d.slug, redirect.redirect_document().slug) # Delete the document, and make sure redirect is gone: d.delete() rebuild_kb() eq_(0, Document.objects.filter(slug=slug).count())
def rebuild_kb(): # If rebuild on demand switch is on, do nothing. if waffle.switch_is_active('wiki-rebuild-on-demand'): return tasks.rebuild_kb()
def rebuild_kb(): tasks.rebuild_kb()