How to use delete_saved_queries method in autotest

Best Python code snippet using autotest_python

public_api_client.py

Source:public_api_client.py Github

copy

Full Screen

...56 def list_schemas_query(self) -> DocumentNode:57 return self._load("list_schemas")58 def update_schema_mutation(self) -> DocumentNode:59 return self._load("create_or_update_schema")60 def delete_saved_queries(self) -> DocumentNode:61 return self._load("delete_saved_queries")62 def configsdk_upload_mutation(self) -> DocumentNode:63 return self._load("sdk_upload")64 def _load(self, name: str) -> DocumentNode:65 if name not in self._cache:66 self._cache[name] = Path(_get_graphql_content_filepath(name)).read_text()67 return gql(self._cache[name])68class PublicAPIClient(Client):69 _user_id: str70 _requests: PublicAPIRequests71 _gql_client: GraphQLClient72 def __init__(self, opts: PublicAPIClientOptions):73 self._user_id = opts.user_id74 self._requests = PublicAPIRequests()75 self._gql_client = _build_client(opts.host, opts.token)76 def check(self) -> BackendCheckResponse:77 res = self._execute(self._requests.version_query())78 if res.errors:79 for err in res.errors:80 logging.error(err.message)81 return BackendCheckResponse(82 success=False,83 message="connection check failed"84 )85 if res.data is None:86 return BackendCheckResponse(87 success=False,88 message="backend sent empty response"89 )90 panther_version = res.data.get("generalSettings", {}).get("pantherVersion")91 if panther_version is None:92 return BackendCheckResponse(93 success=False,94 message="did not receive version in response",95 )96 return BackendCheckResponse(97 success=True,98 message=f"connected to Panther backend on version: {panther_version}"99 )100 def bulk_upload(self, params: BulkUploadParams) -> BackendResponse[BulkUploadResponse]:101 query = self._requests.bulk_upload_mutation()102 upload_params = {"input": {"data": params.encoded_bytes()}}103 default_stats = dict(total=0, new=0, modified=0)104 res = self._execute(query, variable_values=upload_params)105 if res.errors:106 raise BackendError(res.errors)107 if res.data is None:108 raise BackendError("empty data")109 data = res.data.get("uploadDetectionEntities", {})110 return BackendResponse(111 status_code=200,112 data=BulkUploadResponse(113 rules=BulkUploadStatistics(**data.get('rules', default_stats)),114 policies=BulkUploadStatistics(**data.get('policies', default_stats)),115 data_models=BulkUploadStatistics(**data.get('dataModels', default_stats)),116 lookup_tables=BulkUploadStatistics(**data.get('lookupTables', default_stats)),117 global_helpers=BulkUploadStatistics(**data.get('globalHelpers', default_stats))118 ))119 def delete_saved_queries(self, params: DeleteSavedQueriesParams) -> BackendResponse[DeleteSavedQueriesResponse]:120 query = self._requests.delete_saved_queries()121 delete_params = {"input": {122 "dryRun": params.dry_run,123 "includeDetections": params.include_detections,124 "names": params.names,125 }}126 res = self._execute(query, variable_values=delete_params)127 if res.errors:128 raise BackendError(res.errors)129 if res.data is None:130 raise BackendError("empty data")131 data = res.data.get("deleteSavedQueriesByName", {})132 return BackendResponse(133 status_code=200,134 data=DeleteSavedQueriesResponse(...

Full Screen

Full Screen

test_bulk_delete.py

Source:test_bulk_delete.py Github

copy

Full Screen

1import unittest2from unittest import mock3from panther_analysis_tool.backend.mocks import MockBackend4from panther_analysis_tool.backend.client import BackendResponse, DeleteDetectionsResponse, DeleteSavedQueriesResponse5from panther_analysis_tool.cmd.bulk_delete import _delete_detections_dry_run, _delete_queries_dry_run6class TestBulkDelete(unittest.TestCase):7 def test_delete_detections_dry_run(self) -> None:8 mock_ids = ["1", "2", "3"]9 backend = MockBackend()10 backend.delete_detections = mock.MagicMock(11 return_value=BackendResponse(12 data=DeleteDetectionsResponse(ids=mock_ids, saved_query_names=["a"]),13 status_code=200,14 )15 )16 code, msg = _delete_detections_dry_run(backend, mock_ids)17 self.assertEqual(code, 0)18 self.assertEqual(msg, "")19 def test_delete_queries_dry_run(self) -> None:20 mock_names = ["a", "b", "c"]21 backend = MockBackend()22 backend.delete_saved_queries = mock.MagicMock(23 return_value=BackendResponse(24 data=DeleteSavedQueriesResponse(names=mock_names, detection_ids=["1"]),25 status_code=200,26 )27 )28 code, msg = _delete_queries_dry_run(backend, mock_names)29 self.assertEqual(code, 0)...

Full Screen

Full Screen

mocks.py

Source:mocks.py Github

copy

Full Screen

...19 def list_managed_schemas(self, params: ListSchemasParams) -> BackendResponse[Any]:20 pass21 def update_managed_schema(self, params: UpdateManagedSchemaParams) -> BackendResponse[Any]:22 pass23 def delete_saved_queries(self, params: DeleteSavedQueriesParams) -> BackendResponse[Any]:24 pass25 def delete_detections(self, params: DeleteDetectionsParams) -> BackendResponse[Any]:26 pass27 def configsdk_bulk_upload(self, params: ConfigSDKBulkUploadParams) -> BackendResponse[Any]:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful