From 7fad6c174c30b136bec3e62dbc2332fa729da41a Mon Sep 17 00:00:00 2001 From: Joshua Hiller Date: Wed, 25 Oct 2023 16:39:00 -0400 Subject: [PATCH] Expand deprecation warning unit testing --- tests/test_result_object.py | 51 ++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/tests/test_result_object.py b/tests/test_result_object.py index fbea43ad2..27e104c32 100644 --- a/tests/test_result_object.py +++ b/tests/test_result_object.py @@ -15,6 +15,7 @@ # We'll use Hosts to retrieve data to test results with from falconpy import ( Hosts, + CloudConnectAWS, Result, APIError, RegionSelectError, @@ -26,7 +27,10 @@ Errors, SampleUploads, CSPMRegistration, - UnnecessaryEncodingUsed + UnnecessaryEncodingUsed, + DeprecatedOperation, + DeprecatedClass, + SDKDeprecationWarning ) from falconpy._result._base_dictionary import UnsupportedPythonVersion @@ -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): @@ -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 \ No newline at end of file + 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 \ No newline at end of file