'Test accepting a solution and undoing.'

def test_solve_unsolve(self):

    response = get(self.client, 'questions.details', args=[self.question.id])
    doc = pq(response.content)
    eq_(0, len(doc('div.solution')))
    ans = self.question.answers.all()[0]
    self.client.login(username=self.question.creator.username, password='testpass')
    response = post(self.client, 'questions.solve', args=[self.question.id, ans.id])
    eq_(200, response.status_code)
    doc = pq(response.content)
    eq_(1, len(doc('div.solution')))
    div = doc('h3.is-solution')[0].getparent().getparent()
    eq_(('answer-%s' % ans.id), div.attrib['id'])
    q = Question.objects.get(pk=self.question.id)
    eq_(q.solution, ans)
    eq_(q.solver, self.question.creator)
    AnswerFactory(question=q)
    response = post(self.client, 'questions.solve', args=[self.question.id, ans.id])
    eq_(200, response.status_code)
    q = Question.objects.get(pk=self.question.id)
    eq_(q.solution, ans)
    response = post(self.client, 'questions.unsolve', args=[self.question.id, ans.id])
    q = Question.objects.get(pk=self.question.id)
    eq_(q.solution, None)
    eq_(q.solver, None)
