Best Python code snippet using localstack_python
test_stored_query_crud.py
Source:test_stored_query_crud.py
...70 @patch("brainiak.stored_query.crud.delete_instance")71 def test_delete_stored_query_that_exists(self, mock_delete, mock_get_stored_query, mock_validate_client_id):72 query_id = "existent_query"73 client_id = "client_id"74 self.assertIsNone(crud.delete_stored_query(query_id, client_id))75 @patch("brainiak.stored_query.crud.get_stored_query", return_value=None)76 def test_delete_inexistent_stored_query_raises_error(self, mock_delete):77 query_id = "existent_query"78 client_id = "client_id"79 self.assertRaises(HTTPError, crud.delete_stored_query, query_id, client_id)80 @patch("brainiak.stored_query.crud.get_stored_query", return_value={})81 def test_stored_query_exists(self, mocked_get_stored_query):82 self.assertTrue(crud.stored_query_exists("query_id"))83 @patch("brainiak.stored_query.crud.get_stored_query", return_value=None)84 def test_stored_query_does_not_exist(self, mocked_get_stored_query):85 self.assertFalse(crud.stored_query_exists("query_id"))86 def test_valid_query_for_invalid_query(self):87 query_template = """88 INSERT DATA INTO <xubi> {...
imports.py
Source:imports.py
1import json2import pdfkit3import os4from Core.Exceptions.User import UserCoversNotTheRequestedChannel5from Core.Option_values import delete_cooperation6from Core.profile_views import get_data_for_profile_view7from Core.PayPal_Integration import change_subscription_package8from flask import Flask, render_template9from flask import url_for10from werkzeug.utils import secure_filename11from flask import (12 redirect,13 request,14 session,15 send_file16)17from Core.API.API_Permnissions import (18 check_if_user_owns_campaign19)20from Core.Exceptions.Search import (21 InvalidGETRequest,22 CampaignDoesNotExist23)24from Core.Exceptions.User import (25 UserNotLoggedIn,26 UsernameAlreadyExists27)28from Core.admin.getter_setter.API_EXECUTION_DASHBOARD import (29 get_signup_data_sevendays_influencer,30 get_signup_data_sevendays_company,31 get_signup_data_today_influencer,32 get_signup_data_today_company,33 get_kpis,34 get_dates35)36from Core.admin.usermanagement import (37 delete_influencer_account_with_mail_address_from_database,38 delete_instagram_entry,39 delete_facebook_entry,40 delete_youtube_entry,41 delete_pinterest_entry,42 delete_personal_blog_entry,43 delete_company_profile,44 book_package,45 get_all_reported_profiles,46 delete_influencer_with_id,47 ignore_reported_influencer_db_execution48)49from Core.categories import (50 get_templates_getters_and_setters,51 get_view_data_of_admin_view52)53from Core.dbconn import get_database_connection54from Core.invoice_rendering import (55 create_invoice_db_entry,56 get_data_of_invoice_with_uuid,57 genrate_invoice_token,58 get_book_confirmation_mailing_data_usind_the_uuid59)60from Core.mailing import (61 send_pwd_reset_token,62 send_log_in_alert,63 send_booked_package_confirmation_mail64)65from Core.API.API_Execution import (66 unpin_user_from_campaign,67 delete_campaign_db,68 pin_influencer,69 store_search,70 delete_public_campaign_with_identifier71)72from Core.Usermanagement import (73 check_if_email_already_taken,74 create_user,75 create_company_profile,76 validate_data_using_union_view,77 set_confirm_status_to_true,78 set_new_password,79 get_subscription_package_of_company_with_identifier,80 report_influencer)81from Core.campaigns import (82 get_campaigns_basic_view,83 get_data_of_specific_campaign,84 add_campaign, edit_campaign85)86from Core.public_campaigns import (87 add_public_campaign,88 get_all_public_campaigns,89 get_all_public_campaigns_that_fit_with,90 get_details_of_public_campaign_with_identifier,91 get_campaigns_of_company_with_identifier,92 get_pdf_source, update_campaign)93from Core.search import (94 search_influencer_related,95 search_instagrammer,96 get_matching_profiles_as_list,97 get_passed_params_back,98 get_stored_queries_of_company,99 delete_stored_query...
crud.py
Source:crud.py
...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)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!