def test_section_images_ordering(api_client, default_hearing): """ Check images order matches ordering-field """ section_images = default_hearing.sections.first().images.all() # Test some initial order ordered_image_names = list(IMAGES.values()) set_images_ordering(section_images, ordered_image_names) data = get_data_from_response( api_client.get(get_hearing_detail_url(default_hearing.id, 'sections'))) first_section_data = data[0] assert [ im['title'][default_lang_code] for im in first_section_data['images'] ] == ordered_image_names # Test same order reversed reversed_image_names = list(reversed(ordered_image_names)) set_images_ordering(section_images, reversed_image_names) data = get_data_from_response( api_client.get(get_hearing_detail_url(default_hearing.id, 'sections'))) first_section_data = data[0] assert [ im['title'][default_lang_code] for im in first_section_data['images'] ] == reversed_image_names
def check_entity_images(entity): assert 'images' in entity image_list = entity['images'] assert len(image_list) == 3 assert all([im['url'].startswith("http") for im in image_list]) assert set(im['title'] for im in image_list) == set(IMAGES.values()) for im in image_list: assert 'caption' in im assert 'title' in im assert 'width' in im assert 'height' in im assert 'url' in im
def check_entity_images(entity, images_field=True): if images_field: assert 'images' in entity image_list = entity['images'] if images_field else entity assert len(image_list) == 3 assert all([im['url'].startswith("http") for im in image_list]) assert set(im['title'][default_lang_code] for im in image_list) == set(IMAGES.values()) for im in image_list: assert 'caption' in im assert 'title' in im assert 'width' in im assert 'height' in im assert 'url' in im