def test_get_topics(self): """Test the get_topics() method.""" en_us = DocumentFactory(topics=TopicFactory.create_batch(2)) eq_(2, len(en_us.get_topics())) # Localized document inherits parent's topics. DocumentFactory(parent=en_us) eq_(2, len(en_us.get_topics()))
def test_product_landing(self): """Verify that /products/<slug> page renders topics.""" # Create a product. p = ProductFactory() locale = QuestionLocale.objects.get(locale=settings.LANGUAGE_CODE) p.questions_locales.add(locale) # Create some topics. TopicFactory(slug=HOT_TOPIC_SLUG, product=p, visible=True) topics = TopicFactory.create_batch(11, product=p, visible=True) # Create a document and assign the product and 10 topics. d = DocumentFactory(products=[p], topics=topics[:10]) ApprovedRevisionFactory(document=d) self.refresh() # GET the product landing page and verify the content. url = reverse("products.product", args=[p.slug]) r = self.client.get(url, follow=True) eq_(200, r.status_code) doc = pq(r.content) eq_(11, len(doc("#help-topics li"))) eq_(p.slug, doc("#support-search input[name=product]").attr["value"])
def test_product_landing(self): """Verify that /products/<slug> page renders topics.""" # Create a product. p = ProductFactory() l = QuestionLocale.objects.get(locale=settings.LANGUAGE_CODE) p.questions_locales.add(l) # Create some topics. TopicFactory(slug=HOT_TOPIC_SLUG, product=p, visible=True) topics = TopicFactory.create_batch(11, product=p, visible=True) # Create a document and assign the product and 10 topics. d = DocumentFactory(products=[p], topics=topics[:10]) ApprovedRevisionFactory(document=d) self.refresh() # GET the product landing page and verify the content. url = reverse('products.product', args=[p.slug]) r = self.client.get(url, follow=True) eq_(200, r.status_code) doc = pq(r.content) eq_(11, len(doc('#help-topics li'))) eq_(p.slug, doc('#support-search input[name=product]').attr['value'])