def test_is_proxy_fail(self): """Verify that AnsibleJsonFail exception is thrown when exception occurs.""" initial = {"max_records": 1000, "log_level": "writeOnly", "full_policy": "overWrite", "threshold": 90} 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 retrieve the webservices about information"): with mock.patch(self.REQ_FUNC, return_value=Exception()): audit_log.is_proxy()
def test_is_proxy_pass(self): """Verify that True is returned when proxy is used to communicate with storage.""" initial = {"max_records": 1000, "log_level": "writeOnly", "full_policy": "overWrite", "threshold": 90, "api_url": "https://10.1.1.10/devmgr/v2"} self._set_args(**initial) with mock.patch(self.REQ_FUNC, return_value=(200, {"runningAsProxy": True})): audit_log = AuditLog() with mock.patch(self.REQ_FUNC, return_value=(200, {"runningAsProxy": True})): self.assertTrue(audit_log.is_proxy())