Best Python code snippet using localstack_python
test_list_virtual_mfa_devices.py
Source: test_list_virtual_mfa_devices.py
...33 # mock response API list_virtual_mfa_devices34 with patch.object(client_connect_iam,35 'list_virtual_mfa_devices') as mock_method:36 mock_method.return_value = expected_list_virtual_mfa_devices37 actual_list_virtual_mfa_devices = IAMUtils.list_virtual_mfa_devices(38 trace_id, session, aws_account)39 # check response40 self.assertEqual(41 expected_list_virtual_mfa_devices['VirtualMFADevices'],42 actual_list_virtual_mfa_devices)43 # check connect client44 mock_method_client.assert_any_call(service_name="iam")45 @mock_iam46 def test_list_virtual_mfa_devices_success_response_is_truncate_true(self):47 # connect client48 client_connect_iam = iam_utils.client_connect()49 expected_list_virtual_mfa_devices = copy.deepcopy(50 DataTestIAM.LIST_VIRTUAL_MFA_DEVICES_DATA)51 # mock client52 with patch.object(session, 'client') as mock_method_client:53 mock_method_client.return_value = client_connect_iam54 # mock response API list_virtual_mfa_devices55 with patch.object(client_connect_iam,56 'list_virtual_mfa_devices') as mock_method:57 mock_method.side_effect = iam_utils.side_effect_list_virtual_mfa_devices58 actual_list_virtual_mfa_devices = IAMUtils.list_virtual_mfa_devices(59 trace_id, session, aws_account)60 # check response61 self.assertEqual(expected_list_virtual_mfa_devices,62 actual_list_virtual_mfa_devices)63 # check connect client64 mock_method_client.assert_any_call(service_name="iam")65 def test_list_virtual_mfa_devices_error_connect_iam(self):66 expected_error_response = copy.deepcopy(DataCommon.ERROR_RESPONSE)67 expected_operation_name = copy.deepcopy(DataCommon.OPERATION_NAME)68 # mock error client69 with patch.object(session, 'client') as mock_method:70 mock_method.side_effect = ClientError(71 error_response=expected_error_response,72 operation_name=expected_operation_name)73 with patch.object(74 PmLogAdapter, 'error',75 return_value=None) as mock_method_error:76 with self.assertRaises(PmError) as exception:77 IAMUtils.list_virtual_mfa_devices(trace_id, session,78 aws_account)79 # check error80 actual_cause_error = exception.exception.cause_error81 self.assertEqual(expected_error_response['Error'],82 actual_cause_error.response['Error'])83 self.assertEqual(expected_operation_name,84 actual_cause_error.operation_name)85 # check message log error86 mock_method_error.assert_any_call("[%s] IAMã¯ã©ã¤ã¢ã³ãä½æã«å¤±æãã¾ããã",87 aws_account)88 def test_list_virtual_mfa_devices_error_call_list_virtual_mfa_devices(self):89 # connect client90 client_connect_iam = iam_utils.client_connect()91 expected_error_response = copy.deepcopy(DataCommon.ERROR_RESPONSE)92 expected_operation_name = copy.deepcopy(DataCommon.OPERATION_NAME)93 # mock client94 with patch.object(session, 'client') as mock_client:95 mock_client.return_value = client_connect_iam96 # mock error call API list_virtual_mfa_devices97 with patch.object(client_connect_iam,98 'list_virtual_mfa_devices') as mock_method:99 mock_method.side_effect = ClientError(100 error_response=expected_error_response,101 operation_name=expected_operation_name)102 with patch.object(103 PmLogAdapter, 'error',104 return_value=None) as mock_method_error:105 with self.assertRaises(PmError) as exception:106 IAMUtils.list_virtual_mfa_devices(107 trace_id, session, aws_account)108 # check error109 actual_cause_error = exception.exception.cause_error110 self.assertEqual(expected_error_response['Error'],111 actual_cause_error.response['Error'])112 self.assertEqual(expected_operation_name,113 actual_cause_error.operation_name)114 # check message log error115 mock_method_error.assert_any_call("[%s]ä»®æ³MFAããã¤ã¹ãªã¹ãã®åå¾ã«å¤±æãã¾ããã",...
list_mfa_sno.py
Source: list_mfa_sno.py
...22 return users.users23class Getmfa(Resource):24 def put(self,user_name):25 paginator = client.get_paginator('list_virtual_mfa_devices')26 response = client.list_virtual_mfa_devices(AssignmentStatus='Any')27 sno=''28 print '$$$$$$$$$$$$$$$$$$$$$$$$',user_name29 for key, value in response.items():30 if key=='VirtualMFADevices':31 for i in value:32 for k,v in i.items():33 if k=='SerialNumber':34 sno=v35 if k == 'User':36 for u,uv in v.items():37 if u =='UserName' and uv == user_name:38 serial_number=sno39 print serial_number,sno40 return serial_number...
mfa_disassociate.py
Source: mfa_disassociate.py
...7 response = client.deactivate_mfa_device(UserName=user_name,SerialNumber=serial_number)8 print "done"9def get_mfa_serial_number(user_name):10 paginator = client.get_paginator('list_virtual_mfa_devices')11 response = client.list_virtual_mfa_devices(AssignmentStatus='Any')12 sno=''13 for key, value in response.items():14 if key=='VirtualMFADevices':15 for i in value:16 for k,v in i.items():17 if k=='SerialNumber':18 sno=v19 if k == 'User':20 for u,uv in v.items():21 if u =='UserName' and uv == user_name:22 serial_number=sno23 return sno...
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!!