Beispiel #1
0
 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 ')
Beispiel #2
0
    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]]))
Beispiel #3
0
 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 ')
Beispiel #4
0
    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)
Beispiel #5
0
    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
Beispiel #6
0
    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
Beispiel #7
0
    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
Beispiel #8
0
 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()
Beispiel #9
0
 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()
Beispiel #10
0
    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
Beispiel #11
0
 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()
Beispiel #12
0
    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]]),
        )
Beispiel #13
0
    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)
Beispiel #14
0
    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)
Beispiel #15
0
    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]]))
Beispiel #16
0
 def setUp(self):
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #17
0
 def setUp(self):
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #18
0
 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)
Beispiel #19
0
 def setUp(self):
     super(MobileDocumentTests, self).setUp()
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #20
0
 def setUp(self):
     super(MobileDocumentTests, self).setUp()
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #21
0
 def setUp(self):
     super(MinimalViewTests, self).setUp()
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #22
0
 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)
Beispiel #23
0
 def setUp(self):
     super(MinimalViewTests, self).setUp()
     self.doc, _ = doc_rev()
     p = product(save=True)
     self.doc.products.add(p)
     self.doc.save()
Beispiel #24
0
 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)
Beispiel #25
0
 def setUp(self):
     self.d, self.r = doc_rev()
     self.old_title = self.d.title
     self.old_slug = self.d.slug
Beispiel #26
0
 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)
Beispiel #27
0
 def setUp(self):
     self.d, self.r = doc_rev()
     self.old_title = self.d.title
     self.old_slug = self.d.slug