'Verifies subtopics appear on document listing page.'

def test_subtopics(self):

    p = ProductFactory()
    t = TopicFactory(product=p, visible=True)
    doc = DocumentFactory(products=[p], topics=[t])
    ApprovedRevisionFactory(document=doc)
    self.refresh()
    url = reverse('products.documents', args=[p.slug, t.slug])
    r = self.client.get(url, follow=True)
    eq_(200, r.status_code)
    pqdoc = pq(r.content)
    eq_(0, len(pqdoc('li.subtopic')))
    subtopic = TopicFactory(parent=t, product=p, visible=True)
    r = self.client.get(url, follow=True)
    eq_(200, r.status_code)
    pqdoc = pq(r.content)
    eq_(0, len(pqdoc('li.subtopic')))
    doc.topics.add(subtopic)
    self.refresh()
    r = self.client.get(url, follow=True)
    eq_(200, r.status_code)
    pqdoc = pq(r.content)
    eq_(1, len(pqdoc('li.subtopic')))
