'Compares a CourseOverview object against its corresponding
CourseDescriptor object.
Specifically, given a course, test that data within the following three
objects match each other:
- the CourseDescriptor itself
- a CourseOverview that was newly constructed from _create_or_update
- a CourseOverview that was loaded from the MySQL database
Arguments:
course (CourseDescriptor): the course to be checked.'

def check_course_overview_against_course(self, course):

    def get_seconds_since_epoch(date_time):
        '\n                                                Returns    the    number    of    seconds    between    the    Unix    Epoch    and    the    given\n                                                                datetime.    If    the    given    datetime    is    None,    return    None.\n\n                                                Arguments:\n                                                                date_time    (datetime):    the    datetime    in    question.\n                                                '
        if (date_time is None):
            return None
        epoch = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc)
        return math.floor((date_time - epoch).total_seconds())
    course_overview_cache_miss = CourseOverview.get_from_id(course.id)
    course_overview_cache_hit = CourseOverview.get_from_id(course.id)
    fields_to_test = ['id', 'display_name', 'display_number_with_default', 'display_org_with_default', 'advertised_start', 'social_sharing_url', 'certificates_display_behavior', 'certificates_show_before_end', 'cert_name_short', 'cert_name_long', 'lowest_passing_grade', 'end_of_course_survey_url', 'mobile_available', 'visible_to_staff_only', 'location', 'number', 'url_name', 'display_name_with_default', 'display_name_with_default_escaped', 'start_date_is_still_default', 'pre_requisite_courses', 'enrollment_domain', 'invitation_only', 'max_student_enrollments_allowed', 'catalog_visibility']
    for attribute_name in fields_to_test:
        course_value = getattr(course, attribute_name)
        cache_miss_value = getattr(course_overview_cache_miss, attribute_name)
        cache_hit_value = getattr(course_overview_cache_hit, attribute_name)
        self.assertEqual(course_value, cache_miss_value)
        self.assertEqual(cache_miss_value, cache_hit_value)
    methods_to_test = [('clean_id', ()), ('clean_id', ('#',)), ('has_ended', ()), ('has_started', ()), ('may_certify', ())]
    for (method_name, method_args) in methods_to_test:
        course_value = getattr(course, method_name)(*method_args)
        cache_miss_value = getattr(course_overview_cache_miss, method_name)(*method_args)
        cache_hit_value = getattr(course_overview_cache_hit, method_name)(*method_args)
        self.assertEqual(course_value, cache_miss_value)
        self.assertEqual(cache_miss_value, cache_hit_value)
    time_field_accessor = (lambda object, field_name: get_seconds_since_epoch(getattr(object, field_name)))
    course_about_accessor = (lambda object, field_name: CourseDetails.fetch_about_attribute(object.id, field_name))
    others_to_test = [('start', time_field_accessor, time_field_accessor), ('end', time_field_accessor, time_field_accessor), ('enrollment_start', time_field_accessor, time_field_accessor), ('enrollment_end', time_field_accessor, time_field_accessor), ('announcement', time_field_accessor, time_field_accessor), ('short_description', course_about_accessor, getattr), ('effort', course_about_accessor, getattr), ('video', (lambda c, __: CourseDetails.fetch_video_url(c.id)), (lambda c, __: c.course_video_url)), ('course_image_url', (lambda c, __: course_image_url(c)), getattr), ('has_any_active_web_certificate', (lambda c, field_name: (get_active_web_certificate(c) is not None)), getattr)]
    for (attribute_name, course_accessor, course_overview_accessor) in others_to_test:
        course_value = course_accessor(course, attribute_name)
        cache_miss_value = course_overview_accessor(course_overview_cache_miss, attribute_name)
        cache_hit_value = course_overview_accessor(course_overview_cache_hit, attribute_name)
        self.assertEqual(course_value, cache_miss_value)
        self.assertEqual(cache_miss_value, cache_hit_value)
    for course_overview in [course_overview_cache_miss, course_overview_cache_hit]:
        course_overview_tabs = course_overview.tabs.all()
        course_resp_tabs = {tab.tab_id for tab in course_overview_tabs}
        self.assertEqual(self.COURSE_OVERVIEW_TABS, course_resp_tabs)
