def test_redirect_suppression(self): """The document view shouldn't redirect when passed redirect=no.""" redirect, _ = doc_rev('REDIRECT [[http://smoo/]]') response = self.client.get( redirect.get_absolute_url() + '?redirect=no', follow=True) self.assertContains(response, 'REDIRECT ')
def test_changing_products(self): """Changing products works as expected.""" d, r = doc_rev() prod_desktop = product(title=u'desktop', save=True) prod_mobile = product(title=u'mobile', save=True) data = new_document_data() data.update({ 'products': [prod_desktop.id, prod_mobile.id], 'title': d.title, 'slug': d.slug, 'form': 'doc' }) self.client.post(reverse('wiki.edit_document', args=[d.slug]), data) eq_( sorted( Document.uncached.get(slug=d.slug).products.values_list( 'id', flat=True)), sorted([prod.id for prod in [prod_desktop, prod_mobile]])) data.update({'products': [prod_desktop.id], 'form': 'doc'}) self.client.post(reverse('wiki.edit_document', args=[data['slug']]), data) eq_( sorted( Document.uncached.get(slug=d.slug).products.values_list( 'id', flat=True)), sorted([prod.id for prod in [prod_desktop]]))
def test_redirect_suppression(self): """The document view shouldn't redirect when passed redirect=no.""" redirect, _ = doc_rev('REDIRECT [[http://smoo/]]') response = self.client.get(redirect.get_absolute_url() + '?redirect=no', follow=True) self.assertContains(response, 'REDIRECT ')
def test_trans_lock_workflow(self): """End to end test of locking on a translated document.""" doc, _ = doc_rev() u = user(save=True, password='******') # Create a new translation of doc() using the translation view self.client.login(username=u.username, password='******') trans_url = reverse('wiki.translate', locale='es', args=[doc.slug]) data = { 'title': 'Un Test Articulo', 'slug': 'un-test-articulo', 'keywords': 'keyUno, keyDos, keyTres', 'summary': 'lipsumo', 'content': 'loremo ipsumo doloro sito ameto' } r = self.client.post(trans_url, data) eq_(r.status_code, 302) # Now run the test. edit_url = reverse('wiki.edit_document', locale='es', args=[data['slug']]) es_doc = Document.objects.get(slug=data['slug']) eq_(es_doc.locale, 'es') self._lock_workflow(es_doc, edit_url)
def test_unapproved_revision_not_updates_html(self): """Creating an unapproved revision does not update document.html""" d, _ = doc_rev("Here to stay") assert "Here to stay" in d.html, '"Here to stay" not in %s' % d.html # Creating another approved revision keeps initial content r = revision(document=d, content="Fail to replace html") r.save() assert "Here to stay" in d.html, '"Here to stay" not in %s' % d.html
def test_unapproved_revision_not_updates_html(self): """Creating an unapproved revision does not update document.html""" d, _ = doc_rev('Here to stay') assert 'Here to stay' in d.html, '"Here to stay" not in %s' % d.html # Creating another approved revision keeps initial content r = revision(document=d, content='Fail to replace html') r.save() assert 'Here to stay' in d.html, '"Here to stay" not in %s' % d.html
def test_approved_revision_updates_html(self): """Creating an approved revision updates document.html""" d, _ = doc_rev("Replace document html") assert "Replace document html" in d.html, '"Replace document html" not in %s' % d.html # Creating another approved revision replaces it again r = revision(document=d, content="Replace html again", is_approved=True) r.save() assert "Replace html again" in d.html, '"Replace html again" not in %s' % d.html
def test_retitling(self): """When the title of an article is edited, a redirect is made.""" # Not testing slug changes separately; the model tests cover those plus # slug+title changes. If title changes work in the view, the rest # should also. new_title = "Some New Title" d, r = doc_rev() old_title = d.title data = new_document_data() data.update({"title": new_title, "slug": d.slug, "form": "doc"}) self.client.post(reverse("wiki.edit_document", args=[d.slug]), data) eq_(new_title, Document.objects.get(slug=d.slug).title) assert Document.objects.get(title=old_title).redirect_url()
def test_retitling(self): """When the title of an article is edited, a redirect is made.""" # Not testing slug changes separately; the model tests cover those plus # slug+title changes. If title changes work in the view, the rest # should also. new_title = 'Some New Title' d, r = doc_rev() old_title = d.title data = new_document_data() data.update({'title': new_title, 'slug': d.slug, 'form': 'doc'}) self.client.post(reverse('wiki.edit_document', args=[d.slug]), data) eq_(new_title, Document.uncached.get(slug=d.slug).title) assert Document.uncached.get(title=old_title).redirect_url()
def test_approved_revision_updates_html(self): """Creating an approved revision updates document.html""" d, _ = doc_rev('Replace document html') assert 'Replace document html' in d.html, \ '"Replace document html" not in %s' % d.html # Creating another approved revision replaces it again r = revision(document=d, content='Replace html again', is_approved=True) r.save() assert 'Replace html again' in d.html, \ '"Replace html again" not in %s' % d.html
def test_changing_products(self): """Changing products works as expected.""" d, r = doc_rev() prod_desktop = product(title=u"desktop", save=True) prod_mobile = product(title=u"mobile", save=True) data = new_document_data() data.update({"products": [prod_desktop.id, prod_mobile.id], "title": d.title, "slug": d.slug, "form": "doc"}) self.client.post(reverse("wiki.edit_document", args=[d.slug]), data) eq_( sorted(Document.objects.get(slug=d.slug).products.values_list("id", flat=True)), sorted([prod.id for prod in [prod_desktop, prod_mobile]]), ) data.update({"products": [prod_desktop.id], "form": "doc"}) self.client.post(reverse("wiki.edit_document", args=[data["slug"]]), data) eq_( sorted(Document.objects.get(slug=d.slug).products.values_list("id", flat=True)), sorted([prod.id for prod in [prod_desktop]]), )
def test_trans_lock_workflow(self): """End to end test of locking on a translated document.""" doc, _ = doc_rev() u = user(save=True, password='******') # Create a new translation of doc() using the translation view self.client.login(username=u.username, password='******') trans_url = reverse('wiki.translate', locale='es', args=[doc.slug]) data = { 'title': 'Un Test Articulo', 'slug': 'un-test-articulo', 'keywords': 'keyUno, keyDos, keyTres', 'summary': 'lipsumo', 'content': 'loremo ipsumo doloro sito ameto'} r = self.client.post(trans_url, data) eq_(r.status_code, 302) # Now run the test. edit_url = reverse('wiki.edit_document', locale='es', args=[data['slug']]) es_doc = Document.objects.get(slug=data['slug']) eq_(es_doc.locale, 'es') self._lock_workflow(es_doc, edit_url)
def test_trans_lock_workflow(self): """End to end test of locking on a translated document.""" doc, _ = doc_rev() u = user(save=True, password="******") # Create a new translation of doc() using the translation view self.client.login(username=u.username, password="******") trans_url = reverse("wiki.translate", locale="es", args=[doc.slug]) data = { "title": "Un Test Articulo", "slug": "un-test-articulo", "keywords": "keyUno, keyDos, keyTres", "summary": "lipsumo", "content": "loremo ipsumo doloro sito ameto", } r = self.client.post(trans_url, data) eq_(r.status_code, 302) # Now run the test. edit_url = reverse("wiki.edit_document", locale="es", args=[data["slug"]]) es_doc = Document.objects.get(slug=data["slug"]) eq_(es_doc.locale, "es") self._lock_workflow(es_doc, edit_url)
def test_changing_products(self): """Changing products works as expected.""" d, r = doc_rev() prod_desktop = product(title=u'desktop', save=True) prod_mobile = product(title=u'mobile', save=True) data = new_document_data() data.update({'products': [prod_desktop.id, prod_mobile.id], 'title': d.title, 'slug': d.slug, 'form': 'doc'}) self.client.post(reverse('wiki.edit_document', args=[d.slug]), data) eq_(sorted(Document.uncached.get(slug=d.slug).products.values_list( 'id', flat=True)), sorted([prod.id for prod in [prod_desktop, prod_mobile]])) data.update({'products': [prod_desktop.id], 'form': 'doc'}) self.client.post(reverse('wiki.edit_document', args=[data['slug']]), data) eq_(sorted(Document.uncached.get(slug=d.slug).products.values_list( 'id', flat=True)), sorted([prod.id for prod in [prod_desktop]]))
def setUp(self): self.doc, _ = doc_rev() p = product(save=True) self.doc.products.add(p) self.doc.save()
def test_doc_lock_workflow(self): """End to end test of locking on an english document.""" doc, rev = doc_rev() url = reverse('wiki.edit_document', args=[doc.slug], locale='en-US') self._lock_workflow(doc, url)
def setUp(self): super(MobileDocumentTests, self).setUp() self.doc, _ = doc_rev() p = product(save=True) self.doc.products.add(p) self.doc.save()
def setUp(self): super(MinimalViewTests, self).setUp() self.doc, _ = doc_rev() p = product(save=True) self.doc.products.add(p) self.doc.save()
def test_revision_unicode(self): """Revision containing unicode characters is saved successfully.""" str = u' \r\nFirefox informa\xe7\xf5es \u30d8\u30eb' _, r = doc_rev(str) eq_(str, r.content)
def setUp(self): self.d, self.r = doc_rev() self.old_title = self.d.title self.old_slug = self.d.slug
def test_revision_unicode(self): """Revision containing unicode characters is saved successfully.""" str = u" \r\nFirefox informa\xe7\xf5es \u30d8\u30eb" _, r = doc_rev(str) eq_(str, r.content)