Best Python code snippet using localstack_python
client_create_request_model.py
Source: client_create_request_model.py
...60 self.type = type61 if roles is not None:62 self.roles = roles63 @property64 def create_access_key(self):65 """Gets the create_access_key of this ClientCreateRequestModel. # noqa: E50166 Controls whether or not to create an access key for the client. # noqa: E50167 :return: The create_access_key of this ClientCreateRequestModel. # noqa: E50168 :rtype: bool69 """70 return self._create_access_key71 @create_access_key.setter72 def create_access_key(self, create_access_key):73 """Sets the create_access_key of this ClientCreateRequestModel.74 Controls whether or not to create an access key for the client. # noqa: E50175 :param create_access_key: The create_access_key of this ClientCreateRequestModel. # noqa: E50176 :type: bool77 """78 self._create_access_key = create_access_key79 @property80 def access_key_name(self):81 """Gets the access_key_name of this ClientCreateRequestModel. # noqa: E50182 The name that the access key will be assigned. # noqa: E50183 :return: The access_key_name of this ClientCreateRequestModel. # noqa: E50184 :rtype: str85 """86 return self._access_key_name...
test_keymgt.py
Source: test_keymgt.py
1from unittest.mock import patch, MagicMock2from akm.internal import keymgt3import pytest4from botocore.exceptions import ClientError5@patch("akm.internal.keymgt.datetime")6def test_is_delta_between_date_less_than_two_days(mock_datetime, current_mocked_date, creation_mocked_date):7 mock_datetime.now.return_value = current_mocked_date8 assert keymgt.is_access_key_expired(creation_mocked_date, 30) is True9 assert keymgt.is_access_key_expired(creation_mocked_date, 90) is False10def test_check_access_key_exist(iam_list_ak_response):11 assert keymgt.check_access_key_exist("AKIA111111111EXAMPLE", iam_list_ak_response) == {12 "AccessKeyId": "AKIA111111111EXAMPLE",13 }14 with pytest.raises(SystemExit) as sys_exit:15 keymgt.check_access_key_exist("AKIA111111111WRONG", iam_list_ak_response)16 assert sys_exit.type == SystemExit17 assert sys_exit.value.code == "Your profile access key does not match with an user access key"18def test_renew(iam_create_access_key_return):19 iam = MagicMock()20 aws_config = MagicMock()21 iam.create_access_key.return_value = iam_create_access_key_return22 iam.update_access_key.return_value = None23 aws_config.get_profile_ak_id.return_value = None24 deactivate = True25 assert keymgt.renew(aws_config, iam, deactivate, "profile", "user_name") == iam_create_access_key_return26def test_renew_fails(iam_limit_exceeded_exception):27 iam = MagicMock()28 iam.create_access_key = MagicMock(side_effect=ClientError(iam_limit_exceeded_exception, "create_access_key"))29 with pytest.raises(ClientError) as result:30 keymgt.renew("", iam, "", "", "")31 assert "LimitExceededException" in str(result.value)32def test_renew_deactivate_fails(iam_create_access_key_return, boto_standard_error):33 iam = MagicMock()34 aws_config = MagicMock()35 iam.create_access_key.return_value = iam_create_access_key_return36 iam.update_access_key = MagicMock(side_effect=ClientError(boto_standard_error, "create_access_key"))37 aws_config.get_profile_ak_id.return_value = None38 deactivate = True39 with pytest.raises(ClientError) as result:40 keymgt.renew(aws_config, iam, deactivate, "", "")41 assert "WhatEver" in str(result.value)42def test_renew_delete(iam_create_access_key_return):43 iam = MagicMock()44 aws_config = MagicMock()45 iam.create_access_key.return_value = iam_create_access_key_return46 iam.delete_access_key.return_value = None47 aws_config.get_profile_ak_id.return_value = None48 deactivate = False49 assert keymgt.renew(aws_config, iam, deactivate, "profile", "user_name") == iam_create_access_key_return50def test_renew_delete_fails(iam_create_access_key_return, boto_standard_error):51 iam = MagicMock()52 aws_config = MagicMock()53 iam.create_access_key.return_value = iam_create_access_key_return54 iam.delete_access_key = MagicMock(side_effect=ClientError(boto_standard_error, "create_access_key"))55 aws_config.get_profile_ak_id.return_value = None56 deactivate = False57 with pytest.raises(ClientError) as result:58 keymgt.renew(aws_config, iam, deactivate, "", "")...
create_access_key.py
Source: create_access_key.py
2# encoding: utf-83from aws_api import aws_connection_context4from list_profiles import get_list_profiles_output5from list_access_keys import get_list_access_keys6def create_access_key(conn_context):7 result = conn_context.create_access_key()8 return result9if __name__ == '__main__':10 print(get_list_profiles_output())11 profile_name = str(input('Enter profile name to be used in AWS context: '))12 iam = aws_connection_context(profile_name)13 # print list of current access keys14 list_access_keys = get_list_access_keys(conn_context=iam)15 if len(list_access_keys) >= 2:16 print('User already has maximum allowed 2 access keys. Please delete one of them before creating a new one')17 else:18 new_access_key = create_access_key(conn_context=iam)19 new_access_key_id = new_access_key.get('AccessKey').get('AccessKeyId')20 new_access_key_secret = new_access_key.get('AccessKey').get('SecretAccessKey')...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!