'Check that the course has the expected blocks and does not have the unexpected blocks'

@contract(expected_blocks='list(BlockKey)', unexpected_blocks='list(BlockKey)')
def _check_course(self, source_course_loc, dest_course_loc, expected_blocks, unexpected_blocks):

    history_info = modulestore().get_course_history_info(dest_course_loc)
    self.assertEqual(history_info['edited_by'], self.user_id)
    for expected in expected_blocks:
        source = modulestore().get_item(source_course_loc.make_usage_key(expected.type, expected.id))
        pub_copy = modulestore().get_item(dest_course_loc.make_usage_key(expected.type, expected.id))
        self.assertEqual(source.category, pub_copy.category)
        self.assertEqual(source.update_version, pub_copy.source_version, u"Versions    don't    match    for    {}:    {}    !=    {}".format(expected, source.update_version, pub_copy.update_version))
        self.assertEqual(self.user_id, pub_copy.edited_by, '{}    edited_by    {}    not    {}'.format(pub_copy.location, pub_copy.edited_by, self.user_id))
        for field in source.fields.values():
            if (field.name == 'children'):
                self._compare_children(field.read_from(source), field.read_from(pub_copy), unexpected_blocks)
            elif isinstance(field, (Reference, ReferenceList, ReferenceValueDict)):
                self.assertReferenceEqual(field.read_from(source), field.read_from(pub_copy))
            else:
                self.assertEqual(field.read_from(source), field.read_from(pub_copy))
    for unexp in unexpected_blocks:
        with self.assertRaises(ItemNotFoundError):
            modulestore().get_item(dest_course_loc.make_usage_key(unexp.type, unexp.id))
