How to use is_local_env method in localstack

Best Python code snippet using localstack_python

awsenv.py

Source:awsenv.py Github

copy

Full Screen

...18 check whether local dynamodb is set up19 """20 # This is set on template-samp.yaml21 return os.getenv("TEST_ENV") == "LOCAL_DYNAMO_SERVER"22def is_local_env():23 """24 check whether it is local env which doesn't have real aws set up.25 This is set up on template-sam.yaml26 :return:27 """28 # This is set on template-samp.yaml29 logging.info(f"ENVIRONMENT: {os.getenv('TEST_ENV')}")30 return os.getenv("TEST_ENV") == "LOCAL" or is_local_dynamo()31def get_params_from_ssm(path_to_config=None):32 """33 :param path_to_config: path to the config in Parameter store34 :return: dictionary of parameters35 """36 config_path = "/need_to_change_to_correct_path"37 path_to_config = path_to_config or os.getenv("CONFIG_SSM_PARAMETER", config_path)38 ssm = boto3.Session(region_name='us-east-1').client('ssm')39 param = ssm.get_parameter(Name=path_to_config, WithDecryption=True)40 param_dict = {}41 if param and "Parameter" in param:42 param_dict = json.loads(param['Parameter']['Value'])43 return param_dict44def get_params_from_secretsmanager(path_to_config=None):45 """46 :param path_to_config: secrete location47 :return:48 """49 client = boto3.Session().client(service_name="secretsmanager", region_name="us-east-1")50 response = client.get_secret_value(SecretId=path_to_config)51 param_dict = json.loads(response.get('SecretString', "{}"))52 return param_dict53def dynamo_endpoint():54 """55 returns dynamodb endpoint56 """57 # check local dynamo first58 if is_local_dynamo():59 return LOCAL_DYNAMO_SERVER_ENDPOINT60 if is_local_env():61 return LOCALSTACK_ENDPOINT62 return None63def s3_endpoint():64 """65 returns s3 endpoint66 """67 return LOCALSTACK_ENDPOINT if is_local_env() else None68def sqs_endpoint():69 """70 returns sqs endpoint71 """72 return LOCALSTACK_ENDPOINT if is_local_env() else None73def dynamo_table_name():74 """75 returns table name from parameter store76 """77 if is_local_env():78 return LOCAL_TABLE_NAME79 # get data from parameter store with correct key80 # table_name = get_params_from_ssm()["CORRECT_KEY"]81 return "table_name"82def s3_bucket_name():83 """84 returns s3 bucket name from parameter store85 """86 if is_local_env():87 return LOCAL_BUCKET_NAME88 # get data from parameter store with correct key89 # bucket_name = get_params_from_ssm()["CORRECT_KEY"]90 return "bucket_name"91def sqs_name():92 """93 returns sqs name from parameter store94 """95 if is_local_env():96 return LOCAL_QUEUE_NAME97 # get data from parameter store with correct key98 # sqs_name = get_params_from_ssm()["CORRECT_KEY"]...

Full Screen

Full Screen

conftest.py

Source:conftest.py Github

copy

Full Screen

...17 return (token_farm, dapp_token)18def get_farm_and_token(farm_and_token):19 return farm_and_token[0], farm_and_token[1]20def skip_if_not_local_env():21 if not is_local_env():22 pytest.skip("Only for local testing")23def skip_if_local_env():24 if is_local_env():25 pytest.skip("Only for integration testing")26def is_local_env():...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1import pytest2import os3from firestore.db.connector import is_online4FIREBASE_PATH = os.path.abspath(os.path.join(os.path.expanduser("~"), ".ssh/mcr.json"))5IS_LOCAL_ENV = os.environ.get("FIRESTORE_CONFIG", False)6online = pytest.mark.skipif(7 not (is_online() and IS_LOCAL_ENV), reason="Only run this test if internet connectivity is available"...

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