def test_discard_draft_revision(self): """Check Draft Revision is discarded If a user clicks on Discard button in the translation page, the draft revision should be deleted""" draft = DraftRevisionFactory(creator=self.u) doc = draft.document # Send a request to translate article page to discard the draft trans_url = reverse('wiki.translate', locale=draft.locale, args=[doc.slug]) draft_request = {'discard': 'Discard'} restore_draft_resp = self.client.get(trans_url, draft_request) eq_(200, restore_draft_resp.status_code) # Check if the draft revision is in database draft = DraftRevision.objects.filter(id=draft.id) eq_(False, draft.exists())
def test_discard_draft_revision(self): """Check Draft Revision is discarded If a user clicks on Discard button in the translation page, the draft revision should be deleted""" draft = DraftRevisionFactory(creator=self.u) doc = draft.document # Send a request to translate article page to discard the draft trans_url = reverse("wiki.translate", locale=draft.locale, args=[doc.slug]) draft_request = {"discard": "Discard"} restore_draft_resp = self.client.get(trans_url, draft_request) eq_(200, restore_draft_resp.status_code) # Check if the draft revision is in database draft = DraftRevision.objects.filter(id=draft.id) eq_(False, draft.exists())
def test_draft_revision_restore_in_translation_page(self): """Check Draft Revision is restored when a user click on the Restore Button""" # Create a draft revision draft = DraftRevisionFactory(creator=self.u) doc = draft.document # Now send a get request to the page for restoring the draft trans_url = reverse("wiki.translate", locale=draft.locale, args=[doc.slug]) draft_request = {"restore": "Restore"} restore_draft_resp = self.client.get(trans_url, draft_request) eq_(200, restore_draft_resp.status_code) # Check if the title of the translate page contains the title of draft revision trans_page = pq(restore_draft_resp.content) eq_(draft.content, trans_page("#id_content").text())
def test_draft_revision_discarded_when_submitting_revision(self): """Check draft revision is discarded when submitting a revision A user can have only one Draft revision for each translated document. The draft revision should be deleted automatically when the user submit any revision in the document.""" draft = DraftRevisionFactory(creator=self.u) doc = draft.document locale = draft.locale trans_url = reverse("wiki.translate", locale=locale, args=[doc.slug]) data = { "title": "Un Test Articulo", "slug": "un-test-articulo", "keywords": "keyUno, keyDos, keyTres", "summary": "lipsumo", "content": "loremo ipsumo doloro sito ameto", "form": "both", } self.client.post(trans_url, data) draft_revision = DraftRevision.objects.filter(id=draft.id) eq_(False, draft_revision.exists())
def test_draft_revision_discarded_when_submitting_revision(self): """Check draft revision is discarded when submitting a revision A user can have only one Draft revision for each translated document. The draft revision should be deleted automatically when the user submit any revision in the document.""" draft = DraftRevisionFactory(creator=self.u) doc = draft.document locale = draft.locale trans_url = reverse('wiki.translate', locale=locale, args=[doc.slug]) data = { 'title': 'Un Test Articulo', 'slug': 'un-test-articulo', 'keywords': 'keyUno, keyDos, keyTres', 'summary': 'lipsumo', 'content': 'loremo ipsumo doloro sito ameto', 'form': 'both' } self.client.post(trans_url, data) draft_revision = DraftRevision.objects.filter(id=draft.id) eq_(False, draft_revision.exists())