def test_render_all_chunks_yielding_nones(self): context = Context() chunks = [Iframe(pk=1, region='x'), Iframe(pk=2, region='x'), Iframe(pk=3, region='x'), EditRegionChunk(pk=4, region='x'), Iframe(pk=5, region='x')] chunks2 = list(render_all_chunks(context=context, found_chunks=chunks)) self.assertEqual(len(chunks2), len(chunks) - 1)
def test_render_all_chunks(self): objs = [] for x in range(0, 10): iframe = Iframe(region='test', content_id=1, content_type=self.ct, url='https://news.bbc.co.uk/{0!s}'.format(x), position=x) iframe.full_clean() iframe.pk = x objs.append(iframe) ctx = Context() chunks = render_all_chunks(context=ctx, found_chunks=objs) converted_chunks = list(chunks) self.assertEqual(10, len(converted_chunks)) for num, rendered_chunk in enumerate(converted_chunks): testable = rendered_chunk.output.strip() pos = num + 1 self.assertIn('src="https://news.bbc.co.uk/{0}"'.format(num), testable) self.assertIn('data-position="{0}"'.format(pos), testable) self.assertIn('data-region="test"', testable)