Update factory to include image URL block generation

This commit is contained in:
Ramon Wenger 2018-10-04 13:51:18 +02:00
parent 8811829e3a
commit e524fe6107
1 changed files with 6 additions and 3 deletions

View File

@ -85,7 +85,7 @@ class VideoBlockFactory(wagtail_factories.StructBlockFactory):
model = VideoBlock
block_types = ['text_block', 'basic_knowledge', 'student_entry', 'image_block', 'task']
block_types = ['text_block', 'basic_knowledge', 'student_entry', 'image_url_block', 'task']
class ContentBlockFactory(BasePageFactory):
@ -176,9 +176,12 @@ class ContentBlockFactory(BasePageFactory):
elif block_type == 'assignment':
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'assignment', 'task_text')] = RichText(
fake_paragraph())
elif block_type == 'image_block':
elif block_type == 'image_url_block':
kwargs[
'{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', 'image__title')] = fake_paragraph()
'{}__{}__{}__{}'.format(stream_field_name, i, 'image_url_block', 'title')] = fake_paragraph()
kwargs[
'{}__{}__{}__{}'.format(stream_field_name, i, 'image_url_block',
'url')] = 'https://picsum.photos/400/?random={}'.format(''.join(random.choice('abcdefghiklmn') for _ in range(6)))
elif block_type == 'task':
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'task', 'text')] = RichText(fake_paragraph())