From 35fb99f7f5c024446165fe90042b9606def82bb7 Mon Sep 17 00:00:00 2001 From: Atte Niemi Date: Thu, 17 Oct 2024 15:52:38 +0100 Subject: [PATCH] Update unit tests' mock auth objects to use auto-speccing --- 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.