How to use get_stored_query method in localstack

Best Python code snippet using localstack_python

test_stored_query_crud.py

Source:test_stored_query_crud.py Github

copy

Full Screen

...36 }37 query_id, client_id = "get_all_classes_query", "client_id"38 response = crud.store_query(entry, query_id, client_id)39 self.assertEqual(response, expected_response)40 def test_get_stored_query(self):41 query_example = {42 "_source": {43 "sparql_template": "",44 "description": ""45 }46 }47 query_id = "my_query_id"48 with patch("brainiak.stored_query.crud.get_instance",49 return_value=query_example):50 response = crud.get_stored_query(query_id)51 self.assertEqual(response, query_example["_source"])52 @patch("brainiak.stored_query.crud.get_instance",53 return_value=None)54 def test_get_stored_query_is_none(self, mocked_get_instance):55 query_id = "query_id"56 response = crud.get_stored_query(query_id)57 self.assertEqual(response, None)58 @patch("brainiak.stored_query.crud.get_stored_query",59 return_value=None)60 def test_stored_query_exists_but_it_does_not(self, mock_get_stored_query):61 query_id = "non_existent_query"62 self.assertFalse(crud.stored_query_exists(query_id))63 @patch("brainiak.stored_query.crud.get_stored_query",64 return_value={})65 def test_stored_query_exists_but_it_does(self, mock_get_stored_query):66 query_id = "existent_query"67 self.assertTrue(crud.stored_query_exists(query_id))68 @patch("brainiak.stored_query.crud.validate_client_id")69 @patch("brainiak.stored_query.crud.get_stored_query", return_value={"client_id": "client_id"})70 @patch("brainiak.stored_query.crud.delete_instance")...

Full Screen

Full Screen

get_stored_query.py

Source:get_stored_query.py Github

copy

Full Screen

...65 query_description=self.query_description,66 query_expression=self.query_expression,67 query_id=self.query_id,68 tags=self.tags)69def get_stored_query(query_name: Optional[str] = None,70 opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetStoredQueryResult:71 """72 Resource Type definition for AWS::Config::StoredQuery73 """74 __args__ = dict()75 __args__['queryName'] = query_name76 opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)77 __ret__ = pulumi.runtime.invoke('aws-native:configuration:getStoredQuery', __args__, opts=opts, typ=GetStoredQueryResult).value78 return AwaitableGetStoredQueryResult(79 query_arn=__ret__.query_arn,80 query_description=__ret__.query_description,81 query_expression=__ret__.query_expression,82 query_id=__ret__.query_id,83 tags=__ret__.tags)...

Full Screen

Full Screen

crud.py

Source:crud.py Github

copy

Full Screen

...13QUERY_NOT_FOUND_WHEN_DELETING = u"The query with id '{0}' was not found and, therefore, not deleted."14def store_query(entry, query_id, client_id):15 if not _allowed_query(entry["sparql_template"]):16 raise HTTPError(400, log_message=FORBIDDEN_SPARUL_MESSAGE)17 stored_query = get_stored_query(query_id)18 if stored_query:19 validate_client_id(client_id, stored_query)20 save_instance(entry, ES_INDEX_NAME, ES_TYPE_NAME, query_id)21 return 20022 else:23 save_instance(entry, ES_INDEX_NAME, ES_TYPE_NAME, query_id)24 return 20125def validate_client_id(client_id, stored_query):26 actual_client_id = stored_query["client_id"]27 if not actual_client_id == client_id:28 raise HTTPError(400,29 log_message=QUERY_CREATED_BY_OTHER_CLIENT_ID_MESSAGE)30def get_stored_query(query_id):31 stored_query = get_instance(ES_INDEX_NAME, ES_TYPE_NAME, query_id)32 if stored_query is not None:33 stored_query = stored_query["_source"]34 return stored_query35def stored_query_exists(query_id):36 return get_stored_query(query_id) is not None37def delete_stored_query(query_id, client_id):38 stored_query = get_stored_query(query_id)39 if stored_query:40 validate_client_id(client_id, stored_query)41 delete_instance(ES_INDEX_NAME, ES_TYPE_NAME, query_id)42 else:43 raise HTTPError(404, log_message=QUERY_NOT_FOUND_WHEN_DELETING.format(query_id))44def validate_headers(headers):45 if CLIENT_ID_HEADER not in headers:46 raise HTTPError(400, log_message=MISSING_CLIENT_ID_MESSAGE)47def _allowed_query(query_template):48 query_template = re.sub(r'(/\*.+?\*/)', '', query_template, flags=re.DOTALL)49 match = FORBIDDEN_SPARUL_PATTERN.match(query_template)...

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 localstack 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