def METHOD_NAME(self, mocked_method):
    mocked_method.side_effect = Exception()
    self.assert_models_exist(False, False)
    with self.assertRaisesRegex(CommandError, r'Unable to create ApiAccessConfig\. .*'):
        call_command(self.command, self.user.username, create_config=True)
    self.assert_models_exist(False, False)