Best Python code snippet using localstack_python
test_config_citizen_version.py
Source: test_config_citizen_version.py
...18import pytest19from botocore.exceptions import ClientError20def start_rule_invoke(b3_config,config_rule):21 try:22 previous_rule_invoc_time = b3_config.describe_config_rule_evaluation_status(23 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulInvocationTime']24 b3_config.start_config_rules_evaluation(25 ConfigRuleNames=config_rule )26 except ClientError as e: # Handle LimitExceededException. Exception thrown if an evaluation is in progress or if StartConfigRulesEvaluation API is triggered more than once per minute.27 if e.response['Error']['Code'] == 'LimitExceededException':28 print "Previous evaluation is in progress, Wait for 60sec"29 time.sleep(60) # Wait for 60sec before triggering evaluation30 b3_config.start_config_rules_evaluation(31 ConfigRuleNames=config_rule)32 else:33 print "Unexpected error: %s" % e34 return previous_rule_invoc_time35def check_rule_invoke_success(b3_config,config_rule, previous_rule_invoc_time):36 current_rule_invoc_time = previous_rule_invoc_time37 exit_loop_timer = time.time() + 180 # Exit if invocation doesn't start before 3mins38 break_loop = False39 while not (break_loop or current_rule_invoc_time > previous_rule_invoc_time):40 print "Invocation not started..."41 current_rule_invoc_time = b3_config.describe_config_rule_evaluation_status(42 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulInvocationTime']43 if time.time() >= exit_loop_timer:44 print "Invocation Timeout: Invocation did not complete within 3mins..."45 break_loop = True46 print "Invocation has started..."47 return48def check_rule_eval_success(b3_config,config_rule):49 config_rule_invoc_time = b3_config.describe_config_rule_evaluation_status(50 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulInvocationTime']51 config_rule_eval_time = b3_config.describe_config_rule_evaluation_status(52 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulEvaluationTime']53 exit_loop_timer = time.time() + 180 # Exit if Re-evaluation doesn't finish before 3mins54 break_loop = False55 while not break_loop and config_rule_eval_time < config_rule_invoc_time:56 config_rule_invoc_time = b3_config.describe_config_rule_evaluation_status(57 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulInvocationTime']58 config_rule_eval_time = b3_config.describe_config_rule_evaluation_status(59 ConfigRuleNames=config_rule)[u'ConfigRulesEvaluationStatus'][0][u'LastSuccessfulEvaluationTime']60 print "Evaluation not completed..."61 if time.time() >= exit_loop_timer:62 print "Evaluation Timeout: Evaluation did not complete within 3mins"63 break_loop = True64 print "Evaluation has completed..."65 return66def get_rule_eval_status(b3_config, config_rule):67 config_rule_status = b3_config.describe_compliance_by_config_rule(68 ConfigRuleNames=config_rule)[u'ComplianceByConfigRules'][0][u'Compliance'][u'ComplianceType']69 return config_rule_status70### entry point ###71if os.environ['prefix']:72 PREFIX = os.environ['prefix']...
configservice.py
Source: configservice.py
...36 return last_invoked37def rules_status(rulename, cluster, logger):38 client = get_client(cluster)39 if rulename:40 resp = client.describe_config_rule_evaluation_status(ConfigRuleNames=[rulename], 41 Limit=50)42 else:43 resp = client.describe_config_rule_evaluation_status(Limit=50)44 fmt = "%-25s %-30s %-30s %-10s %-10s"45 print (fmt % ("Rule name", "Last Invoked", "Last Eval", "Last Error", "Last Err Msg"))46 status_list = resp.get('ConfigRulesEvaluationStatus')47 status_list = filter(48 lambda x : get_max_date(x.get('LastSuccessfulInvocationTime'),x.get('LastFailedInvocationTime')),49 status_list50 )51 status_list = sorted(status_list, 52 key= lambda x : get_max_date(x.get('LastSuccessfulInvocationTime'),53 x.get('LastFailedInvocationTime')))54 for status in status_list:55 last_invoked = get_max_date(status.get('LastSuccessfulInvocationTime'),56 status.get('LastFailedInvocationTime'))57 last_eval = get_max_date(status.get('LastSuccessfulEvaluationTime'), ...
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!!