def METHOD_NAME(self, invalid_key):
    """ Test that raises InvalidKeyError for invalid keys """
    err_string = f"Invalid course_key: '{invalid_key}'"
    with self.assertRaisesRegex(CommandError, err_string):
        call_command('reindex_course', invalid_key)