'Helper method for answer vote tests.'

def common_answer_vote(self):

    response = get(self.client, 'questions.details', args=[self.question.id])
    doc = pq(response.content)
    eq_(1, len(doc('form.helpful    input[name="helpful"]')))
    ua = 'Mozilla/5.0    (DjangoTestClient)'
    self.client.post(reverse('questions.answer_vote', args=[self.question.id, self.answer.id]), {'helpful': 'y'}, HTTP_USER_AGENT=ua)
    response = get(self.client, 'questions.details', args=[self.question.id])
    doc = pq(response.content)
    eq_(1, len(doc(('#answer-%s    h3.is-helpful' % self.answer.id))))
    eq_(0, len(doc('form.helpful    input[name="helpful"]')))
    vote_meta = VoteMetadata.objects.all()[0]
    eq_('ua', vote_meta.key)
    eq_(ua, vote_meta.value)
