'Test setting and unsetting the needs change flag'

def test_needs_change(self):

    comment = 'Please    update    for    Firefix.next'
    doc = RevisionFactory().document
    data = new_document_data()
    data.update({'needs_change': True, 'needs_change_comment': comment, 'form': 'doc'})
    self.client.post(reverse('wiki.edit_document', args=[doc.slug]), data)
    doc = Document.objects.get(pk=doc.pk)
    assert (not doc.needs_change)
    assert (not doc.needs_change_comment)
    add_permission(self.u, Document, 'edit_needs_change')
    self.client.post(reverse('wiki.edit_document', args=[doc.slug]), data)
    doc = Document.objects.get(pk=doc.pk)
    assert doc.needs_change
    eq_(comment, doc.needs_change_comment)
    data.update({'needs_change': False, 'needs_change_comment': comment})
    self.client.post(reverse('wiki.edit_document', args=[doc.slug]), data)
    doc = Document.objects.get(pk=doc.pk)
    assert (not doc.needs_change)
    eq_('', doc.needs_change_comment)
