'Assert that the courses identified by ``expected_course_key`` in ``expected_store`` and
``actual_course_key`` in ``actual_store`` are identical (ignore differences related
owing to the course_keys being different).
Any field value mentioned in ``self.field_exclusions`` by the key (usage_id, field_name)
will be ignored for the purpose of equality checking.'

def assertCoursesEqual(self, expected_store, expected_course_key, actual_store, actual_course_key):

    with expected_store.branch_setting(ModuleStoreEnum.Branch.published_only, expected_course_key):
        with actual_store.branch_setting(ModuleStoreEnum.Branch.published_only, actual_course_key):
            expected_items = expected_store.get_items(expected_course_key, revision=ModuleStoreEnum.RevisionOption.published_only)
            actual_items = actual_store.get_items(actual_course_key, revision=ModuleStoreEnum.RevisionOption.published_only)
            self.assertGreater(len(expected_items), 0)
            self._assertCoursesEqual(expected_items, actual_items, actual_course_key)
    if isinstance(expected_store, ModuleStoreDraftAndPublished):
        with expected_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, expected_course_key):
            with actual_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, actual_course_key):
                if (expected_store.get_modulestore_type(None) == ModuleStoreEnum.Type.split):
                    revision = ModuleStoreEnum.RevisionOption.draft_only
                else:
                    revision = None
                expected_items = expected_store.get_items(expected_course_key, revision=revision)
                if (actual_store.get_modulestore_type(None) == ModuleStoreEnum.Type.split):
                    revision = ModuleStoreEnum.RevisionOption.draft_only
                else:
                    revision = None
                actual_items = actual_store.get_items(actual_course_key, revision=revision)
                self._assertCoursesEqual(expected_items, actual_items, actual_course_key, expect_drafts=True)
