Skip to content

Commit

Permalink
Expand deprecation warning unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed Oct 25, 2023
1 parent d007008 commit 7fad6c1
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions tests/test_result_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# We'll use Hosts to retrieve data to test results with
from falconpy import (
Hosts,
CloudConnectAWS,
Result,
APIError,
RegionSelectError,
Expand All @@ -26,7 +27,10 @@
Errors,
SampleUploads,
CSPMRegistration,
UnnecessaryEncodingUsed
UnnecessaryEncodingUsed,
DeprecatedOperation,
DeprecatedClass,
SDKDeprecationWarning
)
from falconpy._result._base_dictionary import UnsupportedPythonVersion

Expand Down Expand Up @@ -475,16 +479,16 @@ def test_error_simple_response(self):
assert bool((oopsies and oopsies.simple))


# @not_supported
# def test_warning_simple_response(self):
# if _RATE_LIMITED:
# pytest.skip("Rate limited")
# try:
# raise SSLDisabledWarning(code=418,
# message="SSL verification isn't really turned off. I mean... unless you did it?",
# headers={"CrowdStrike": "WE STOP BREACHES"})
# except SSLDisabledWarning as kerblammo:
# assert bool((kerblammo and kerblammo.simple))
@not_supported
def test_warning_simple_response(self):
if _RATE_LIMITED:
pytest.skip("Rate limited")
try:
raise SSLDisabledWarning(code=418,
message="SSL verification isn't really turned off. I mean... unless you did it?",
headers={"CrowdStrike": "WE STOP BREACHES"})
except SSLDisabledWarning as kerblammo:
assert bool((kerblammo and kerblammo.simple))

@not_supported
def test_base_resource_iteration(self):
Expand Down Expand Up @@ -743,4 +747,27 @@ def test_unnecessary_encoding_used_warning(self):
_success = True
hosts = Hosts(auth_object=hosts, pythonic=False)
hosts.query_devices_by_filter_scroll(filter="hostname%3A%27falconpy%27")
assert _success
assert _success

@not_supported
def test_pythonic_deprecation_warnings(self):
_success = False
with pytest.warns(SDKDeprecationWarning):
warnings.warn(SDKDeprecationWarning(message="This is a generic deprecation warning", code=187))
with pytest.warns(DeprecatedClass):
warnings.warn(DeprecatedClass(code=187))
with pytest.warns(DeprecatedOperation):
warnings.warn(DeprecatedOperation(code=187))
with pytest.warns(DeprecatedClass):
try:
old_discover = CloudConnectAWS(auth_object=config, pythonic=True)
except APIError:
pass

with pytest.warns(DeprecatedOperation):
try:
old_discover.get_aws_settings()
_success = True
except:
pass
assert _success

0 comments on commit 7fad6c1

Please sign in to comment.