def test_update_configuration_delete_skip_fail(self):
        """Verify 422 and no force results in AnsibleJsonFail exception."""
        body = {
            "auditLogMaxRecords": 1000,
            "auditLogLevel": "writeOnly",
            "auditLogFullPolicy": "overWrite",
            "auditLogWarningThresholdPct": 90
        }
        initial = {
            "max_records": 2000,
            "log_level": "writeOnly",
            "full_policy": "overWrite",
            "threshold": 90,
            "force": False
        }

        self._set_args(**initial)
        with mock.patch(self.REQ_FUNC,
                        return_value=(200, {
                            "runningAsProxy": True
                        })):
            audit_log = AuditLog()

        with self.assertRaisesRegexp(
                AnsibleFailJson, r"Failed to update audit-log configuration!"):
            with mock.patch(self.REQ_FUNC,
                            side_effect=[(200, body),
                                         Exception(422,
                                                   {"errorMessage": "error"}),
                                         (200, None), (200, None)]):
                audit_log.update_configuration()
    def test_update_configuration_delete_pass(self):
        """Verify 422 and force successfully returns True."""
        body = {
            "auditLogMaxRecords": 1000,
            "auditLogLevel": "writeOnly",
            "auditLogFullPolicy": "overWrite",
            "auditLogWarningThresholdPct": 90
        }
        initial = {
            "max_records": 2000,
            "log_level": "writeOnly",
            "full_policy": "overWrite",
            "threshold": 90,
            "force": True
        }

        self._set_args(**initial)
        with mock.patch(self.REQ_FUNC,
                        return_value=(200, {
                            "runningAsProxy": True
                        })):
            audit_log = AuditLog()
            with mock.patch(self.REQ_FUNC,
                            side_effect=[(200, body),
                                         (422, {
                                             u"invalidFieldsIfKnown": None,
                                             u"errorMessage":
                                             u"Configuration change...",
                                             u"localizedMessage":
                                             u"Configuration change...",
                                             u"retcode":
                                             u"auditLogImmediateFullCondition",
                                             u"codeType": u"devicemgrerror"
                                         }), (200, None), (200, None)]):
                self.assertTrue(audit_log.update_configuration())