def test_prefetch_tuple_sizes(self, enrich_fn, registry): provider, registry = self.mock_provider_and_registry(registry) prefetch(TEXT_CONTENT, sizes=[(100, 200), (300, 400)]) self.assertEqual(enrich_fn.call_count, 3) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=None, maxheight=None) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=100, maxheight=200) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=300, maxheight=400)
def test_prefetch_int_sizes(self, enrich_fn, registry): provider, registry = self.mock_provider_and_registry(registry) prefetch(TEXT_CONTENT, sizes=[100]) self.assertEqual(enrich_fn.call_count, 4) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=None, maxheight=None) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=100, maxheight=None) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=None, maxheight=100) enrich_fn.assert_any_call(TEXT_CONTENT, maxwidth=100, maxheight=100)
def pre_save(self, model, add): prefetch(getattr(model, self.attname), html=False, sizes=self.prefetch_sizes) return super(OEmbedURLField, self).pre_save(model, add)
def pre_save(self, model, add): prefetch(getattr(model, self.attname), html=self.contains_html, sizes=self.prefetch_sizes) return super(OEmbedTextField, self).pre_save(model, add)
def test_prefetch_no_sizes(self, enrich_fn, registry): provider, registry = self.mock_provider_and_registry(registry) prefetch(TEXT_CONTENT) enrich_fn.assert_called_once_with(TEXT_CONTENT, maxwidth=None, maxheight=None)