From abf35ebed08aaf010c67a2c2dd562ede871b5fe1 Mon Sep 17 00:00:00 2001 From: Atte Niemi <4998544+hur@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:04:05 +0100 Subject: [PATCH] Update unit tests' mock auth objects to use auto-speccing (#215) Co-authored-by: Atte Niemi --- tests/unit_tests/test_custom_ioas.py | 2 +- tests/unit_tests/test_hosts.py | 2 +- tests/unit_tests/test_prevention_policies.py | 2 +- tests/unit_tests/test_response_policies.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/test_custom_ioas.py b/tests/unit_tests/test_custom_ioas.py index 639ce9e..647496c 100644 --- a/tests/unit_tests/test_custom_ioas.py +++ b/tests/unit_tests/test_custom_ioas.py @@ -25,7 +25,7 @@ def client(): """Pytest fixture that provides a client with a mocked OAuth2 object, so no API credentials are needed. """ - auth = MagicMock(autospec=falconpy.OAuth2) + auth = MagicMock(spec=falconpy.OAuth2, autospec=True) client = Client(falconpy_authobject=auth) return client diff --git a/tests/unit_tests/test_hosts.py b/tests/unit_tests/test_hosts.py index 476eba6..9ff1dfe 100644 --- a/tests/unit_tests/test_hosts.py +++ b/tests/unit_tests/test_hosts.py @@ -115,7 +115,7 @@ def hosts_test(): def decorator(func): @patch("caracara.modules.hosts.hosts.HostGroup", autospec=falconpy.HostGroup) @patch("caracara.modules.hosts.hosts.Hosts", autospec=falconpy.Hosts) - @patch("caracara.client.OAuth2") + @patch("caracara.client.OAuth2", autospec=True) def new_func(mock_oauth2, mock_hosts, mock_hostgroup): # B106 is a bandit warning for hardcoded passwords. # This is a testing context and the credentials passed to this constructor diff --git a/tests/unit_tests/test_prevention_policies.py b/tests/unit_tests/test_prevention_policies.py index 7c7e8f4..0e3f6f4 100644 --- a/tests/unit_tests/test_prevention_policies.py +++ b/tests/unit_tests/test_prevention_policies.py @@ -17,7 +17,7 @@ def decorator(func): "caracara.modules.prevention_policies.prevention_policies.PreventionPolicies", autospec=falconpy.PreventionPolicies, ) - @patch("caracara.client.OAuth2") + @patch("caracara.client.OAuth2", autospec=True) def test_new_func(mock_oauth2, mock_prevpol): # B106 is a bandit warning for hardcoded passwords. # This is a testing context and the credentials passed to this constructor diff --git a/tests/unit_tests/test_response_policies.py b/tests/unit_tests/test_response_policies.py index bd322f7..cf305f1 100644 --- a/tests/unit_tests/test_response_policies.py +++ b/tests/unit_tests/test_response_policies.py @@ -17,7 +17,7 @@ def decorator(func): "caracara.modules.response_policies.response_policies.ResponsePolicies", autospec=falconpy.ResponsePolicies, ) - @patch("caracara.client.OAuth2") + @patch("caracara.client.OAuth2", autospec=True) def test_new_func(mock_oauth2, mock_prevpol): # B106 is a bandit warning for hardcoded passwords, this is a testing context and # the credentials passed to this constructor aren't valid and aren't used.