'Test the successful image set re-creation on updating
the course overview.'

def test_successful_image_update(self):

    config = CourseOverviewImageConfig.current()
    course_image = 'src_course_image.png'
    updated_course_image = 'src_course_image1.png'
    course = CourseFactory.create(course_image=course_image)
    self._create_course_image(course, course_image)
    overview = CourseOverview.get_from_id(course.id)
    self.assertTrue(hasattr(overview, 'image_set'))
    image_urls = overview.image_urls
    self.assertTrue(image_urls['raw'].endswith('src_course_image.png'))
    self.assertTrue(image_urls['small'].endswith('src_course_image-png-{}x{}.jpg'.format(*config.small)))
    self.assertTrue(image_urls['large'].endswith('src_course_image-png-{}x{}.jpg'.format(*config.large)))
    course.course_image = 'src_course_image1.png'
    self._create_course_image(course, updated_course_image)
    with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred):
        self.store.update_item(course, ModuleStoreEnum.UserID.test)
    image_urls = CourseOverview.objects.get(id=overview.id).image_urls
    self.assertTrue(image_urls['raw'].endswith('src_course_image1.png'))
    self.assertTrue(image_urls['small'].endswith('src_course_image1-png-{}x{}.jpg'.format(*config.small)))
    self.assertTrue(image_urls['large'].endswith('src_course_image1-png-{}x{}.jpg'.format(*config.large)))
