def test_latest_queryset_all(self): """Should return all advisories for the all page.""" advisories = [self.new_advisory() for i in range(10)] req = self.rf.get('/') req.resolver_match = Mock() req.resolver_match.url_name = 'security.advisories' qs = latest_queryset(req, {}) self.assertListEqual(advisories, list(qs.order_by('year', 'order')))
def test_latest_queryset_single(self): """Should return a single advisory based on PK.""" advisories = [self.new_advisory() for i in range(10)] req = self.rf.get('/') req.resolver_match = Mock() req.resolver_match.url_name = 'security.advisory' qs = latest_queryset(req, {'pk': '2014-05'}) self.assertEqual(advisories[4], qs.get())
def test_latest_queryset_product_version(self): """Should advisories for a single product version.""" advisories_30 = [self.new_advisory(fixed_in=['Firefox 30.{0}'.format(i)]) for i in range(5)] advisories_29 = [self.new_advisory(fixed_in=['Firefox 29.0.{0}'.format(i)]) for i in range(1, 5)] # make sure the one with no point version is included advisories_29.append(self.new_advisory(fixed_in=['Firefox 29.0'])) req = self.rf.get('/') req.resolver_match = Mock() req.resolver_match.url_name = 'security.product-version-advisories' qs = latest_queryset(req, {'slug': 'firefox-30'}) self.assertListEqual(advisories_30, list(qs.order_by('year', 'order'))) qs = latest_queryset(req, {'slug': 'firefox-30.1'}) self.assertEqual(advisories_30[1], qs.get()) qs = latest_queryset(req, {'slug': 'firefox-29.0'}) self.assertListEqual(advisories_29, list(qs.order_by('year', 'order')))
def test_latest_queryset_product_version(self): """Should advisories for a single product version.""" advisories_30 = [self.new_advisory(fixed_in=['Firefox 30.{0}'.format(i)]) for i in range(5)] advisories_29 = [self.new_advisory(fixed_in=['Firefox 29.0.{0}'.format(i)]) for i in range(1, 5)] # make sure the one with no point version is included advisories_29.append(self.new_advisory(fixed_in=['Firefox 29.0'])) # make sure the one outside of 29.0 isn't included self.new_advisory(fixed_in=['Firefox 29.1']) req = self.rf.get('/') req.resolver_match = Mock() req.resolver_match.url_name = 'security.product-version-advisories' qs = latest_queryset(req, {'product': 'firefox', 'version': '30'}) self.assertListEqual(advisories_30, list(qs.order_by('year', 'order'))) qs = latest_queryset(req, {'product': 'firefox', 'version': '30.1'}) self.assertEqual(advisories_30[1], qs.get()) qs = latest_queryset(req, {'product': 'firefox', 'version': '29.0'}) self.assertListEqual(advisories_29, list(qs.order_by('year', 'order')))
def test_latest_queryset_product(self): """Should advisories for a single product.""" advisories_fx = [self.new_advisory(fixed_in=['Firefox 30.0']) for i in range(5)] for i in range(5): self.new_advisory(fixed_in=['Thunderbird 30.0']) req = self.rf.get('/') req.resolver_match = Mock() req.resolver_match.url_name = 'security.product-advisories' qs = latest_queryset(req, {'slug': 'firefox'}) self.assertListEqual(advisories_fx, list(qs.order_by('year', 'order')))