def test_preview(self): """Preview the wiki syntax content.""" response = post(self.client, 'wiki.preview', {'content': '<h1>Test Content</h1>'}) eq_(200, response.status_code) doc = pq(response.content) eq_('Test Content', doc('article#wikiArticle h1').text())
def test_change_title_case(self): """Changing the case of some letters in the title should work.""" data = new_document_data() new_title = 'TeST DoCuMent' data.update(title=new_title) data.update(form='doc') response = post(self.client, 'wiki.edit', data, args=[self.d.slug]) eq_(200, response.status_code) doc = Document.objects.get(pk=self.d.pk) eq_(new_title, doc.title)
def test_vote_anonymous(self): """Test that voting works for anonymous user.""" d = self.document response = post(self.client, 'wiki.document_vote', {'helpful': 'Yes'}, args=[d.slug]) eq_(200, response.status_code) votes = HelpfulVote.objects.filter(document=d, creator=None) votes = votes.exclude(anonymous_id=None) eq_(1, votes.count()) assert votes[0].helpful
def test_vote_no(self): """Test voting not helpful.""" d = self.document user = self.user_model.objects.get(username='******') self.client.login(username='******', password='******') response = post(self.client, 'wiki.document_vote', {'not-helpful': 'No'}, args=[d.slug]) eq_(200, response.status_code) votes = HelpfulVote.objects.filter(document=d, creator=user) eq_(1, votes.count()) assert not votes[0].helpful
def test_change_slug_case(self): """Changing the case of some letters in the slug should work.""" data = new_document_data() new_slug = 'Test-Document' data.update(slug=new_slug) data.update(form='doc') response = post(self.client, 'wiki.edit_document', data, args=[self.d.slug]) eq_(200, response.status_code) doc = Document.objects.get(pk=self.d.pk) eq_(new_slug, doc.slug)
def test_can_save_document_with_translations(self): """Make sure we can save a document with translations.""" # Create a translation _create_document(title='Document Prueba', parent=self.d, locale='es') # Make sure is_localizable hidden field is rendered response = get(self.client, 'wiki.edit', args=[self.d.slug]) eq_(200, response.status_code) doc = pq(response.content) data = new_document_data() new_title = 'A brand new title' data.update(title=new_title) data.update(form='doc') data.update(is_localizable='True') response = post(self.client, 'wiki.edit', data, args=[self.d.slug]) eq_(200, response.status_code) doc = Document.objects.get(pk=self.d.pk) eq_(new_title, doc.title)