'Test for race condition in CourseOverviewImageSet creation.
CourseOverviewTestCase already tests for race conditions with
CourseOverview as a whole, but we still need to test the case where a
CourseOverview already exists and we have a race condition purely in the
part that adds a new CourseOverviewImageSet.'

def test_image_creation_race_condition(self):

    self.set_config(False)
    course = CourseFactory.create()
    overview = CourseOverview.get_from_id(course.id)
    self.assertFalse(hasattr(overview, 'image_set'))
    CourseOverviewImageSet.objects.create(course_overview=overview)
    self.set_config(True)
    CourseOverviewImageSet.create(overview)
    self.assertTrue(hasattr(overview, 'image_set'))
    self.set_config(False)
