Skip to content

Commit

Permalink
Update unit tests' mock auth objects to use auto-speccing (#215)
Browse files Browse the repository at this point in the history
Co-authored-by: Atte Niemi <atte.niemi@crowdstrike.com>
  • Loading branch information
hur and hur authored Oct 17, 2024
1 parent 5bc830c commit abf35eb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/unit_tests/test_custom_ioas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_prevention_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_response_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit abf35eb

Please sign in to comment.