def test_webinspect_api_helper_create_scan_success(api_mock, json_dumps_mock, log_scan_start_mock): # Given webinspect_api_helper_object = WebInspectAPIHelper(silent=True, webinspect_setting_overrides=MagicMock()) webinspect_api_helper_object.api.create_scan = api_mock # When webinspect_api_helper_object.create_scan() # Expect assert api_mock.call_count == 1 assert log_scan_start_mock.call_count == 1
def test_webinspect_api_helper_create_scan_failure_value_error(api_mock, json_dumps_mock, log_scan_failed_mock): # Given webinspect_api_helper_object = WebInspectAPIHelper(silent=True, webinspect_setting_overrides=MagicMock()) json_dumps_mock.side_effect = ValueError webinspect_api_helper_object.api.create_scan = api_mock # When with pytest.raises(SystemExit): webinspect_api_helper_object.create_scan() # Expect assert api_mock.call_count == 0 # because it errors before the call assert log_scan_failed_mock.call_count == 1