How to use get_default_account_id method in localstack

Best Python code snippet using localstack_python

test_account.py

Source:test_account.py Github

copy

Full Screen

...4 def test_get_accounts(self):5 accounts = AccountController.get_accounts()6 assert isinstance(accounts, dict)7 assert "accounts" in accounts8 def test_get_default_account_id(self):9 account_id = AccountController.get_default_account_id()10 assert isinstance(account_id, str)11 assert len(account_id) == 2012 def test_get_account_details(self):13 account_id = AccountController.get_default_account_id()14 account_details = AccountController.get_account_details(account_id)15 assert isinstance(account_details, dict)16 assert "account" in account_details17 assert "lastTransactionID" in account_details18 def test_get_account_summary(self):19 account_id = AccountController.get_default_account_id()20 account_summary = AccountController.get_account_summary(account_id)21 assert isinstance(account_summary, dict)22 assert "account" in account_summary23 assert "lastTransactionID" in account_summary24 def test_get_tradeable_instruments(self):25 account_id = AccountController.get_default_account_id()26 tradeable_instruments = AccountController.get_tradeable_instruments(account_id)27 assert isinstance(tradeable_instruments, dict)28 assert "instruments" in tradeable_instruments29 assert "lastTransactionID" in tradeable_instruments30 def test_get_tradeable_instruments_one_instrument(self):31 account_id = AccountController.get_default_account_id()32 tradeable_instruments = AccountController.get_tradeable_instruments(33 account_id, instruments=["USB05Y_USD"]34 )35 assert isinstance(tradeable_instruments, dict)36 assert "instruments" in tradeable_instruments37 assert len(tradeable_instruments["instruments"]) == 138 assert "lastTransactionID" in tradeable_instruments39 def test_get_tradeable_instruments_invalid(self):40 account_id = AccountController.get_default_account_id()41 with pytest.raises(Exception):42 tradeable_instruments = AccountController.get_tradeable_instruments(43 account_id, names_only=True, instruments=["USB05Y_USD"]44 )45 def test_get_tradeable_instruments_names_only(self):46 account_id = AccountController.get_default_account_id()47 tradeable_instruments = AccountController.get_tradeable_instruments(48 account_id, names_only=True49 )...

Full Screen

Full Screen

accounts.py

Source:accounts.py Github

copy

Full Screen

...8REQUEST_CTX_TLS = threading.local()9def get_aws_account_id() -> str:10 """Return the AWS account ID for the current context."""11 return account_id_resolver()12def get_default_account_id() -> str:13 return _TEST_AWS_ACCOUNT_ID14account_id_resolver = get_default_account_id15def get_account_id_from_access_key_id(access_key_id: str) -> str:16 """Return the Account ID associated the Access Key ID."""17 # This utility ignores IAM mappings.18 # For now, we assume the client sends Account ID in Access Key ID field.19 if re.match(r"\d{12}", access_key_id):20 return access_key_id21 else:22 return get_default_account_id()23def get_ctx_aws_access_key_id() -> Optional[str]:24 """Return the AWS access key ID for current context."""25 return getattr(REQUEST_CTX_TLS, "access_key_id", None)26def set_ctx_aws_access_key_id(access_key_id: str):27 REQUEST_CTX_TLS.access_key_id = access_key_id28@hooks.on_infra_start()29def patch_get_account_id():30 """Patch Moto's account ID resolver with our own."""31 import moto.core32 moto.core.models.account_id_resolver = get_aws_account_id33 # Note: Moto templates making use of this constant will not get access to34 # account ID from the current context...

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