def test_work_types_dont_override_provider(self):
"""[#122] Selecting work types should be a subset of providers, not override them"""
img1 = models.Image.objects.create(url='example.com/1', title='hello', provider='flickr')
img2 = models.Image.objects.create(url='example.com/2', title='hello', provider='nypl')
self._index_img(img1)
self._index_img(img2)
# Search by provider=flickr but work type=cultural should limit by Flickr first
resp = self.client.get(self.url, {'search_fields': 'title',
'search': 'hello',
'providers': 'flickr',
'work_types': 'cultural'})
# One result, the correct one
self.assertEqual(1, len(select_nodes(resp, '.t-image-result')))
# We now have also img[data-identifier], which is used by photoswipe
self.assertEqual(1, len(select_nodes(resp, 'div[data-identifier="' + img1.identifier +'"]')))
self.assertEqual(0, len(select_nodes(resp, 'div[data-identifier="' + img2.identifier +'"]')))
评论列表
文章目录