'Test the quick-review button.'

@pytest.mark.review_tags
def test_quick_review(self):

    self.client.login(username='admin', password='testpass')
    test_data = [{'params': {'request_technical': 1}, 'expected_tags': ['technical'], 'name': 'technical', 'message_contains': ['Editorial    review    completed.']}, {'params': {'request_editorial': 1}, 'expected_tags': ['editorial'], 'name': 'editorial', 'message_contains': ['Technical    review    completed.']}, {'params': {}, 'expected_tags': [], 'name': 'editorial-technical', 'message_contains': ['Technical    review    completed.', 'Editorial    review    completed.']}]
    for data_dict in test_data:
        slug = ('test-quick-review-%s' % data_dict['name'])
        data = new_document_data()
        data.update({'review_tags': ['editorial', 'technical'], 'slug': slug})
        resp = self.client.post(reverse('wiki.create'), data)
        doc = Document.objects.get(slug=slug)
        rev = doc.revisions.order_by('-id').all()[0]
        review_url = reverse('wiki.quick_review', args=[doc.slug])
        params = dict(data_dict['params'], revision_id=rev.id)
        resp = self.client.post(review_url, params)
        eq_(302, resp.status_code)
        doc = Document.objects.get(locale=settings.WIKI_DEFAULT_LANGUAGE, slug=slug)
        rev = doc.revisions.order_by('-id').all()[0]
        review_tags = [x.name for x in rev.review_tags.all()]
        review_tags.sort()
        for expected_str in data_dict['message_contains']:
            ok_((expected_str in rev.summary))
            ok_((expected_str in rev.comment))
        eq_(data_dict['expected_tags'], review_tags)
