Best Python code snippet using localstack_python
user_response.py
Source: user_response.py
...59 q['value'] = ''60 continue61 if target not in values:62 continue63 numeric_condition = evaluate_numeric_condition(values[target], q['question__reveal_response'])64 if numeric_condition is None:65 if q['question__reveal_response'] and q['question__reveal_response'] != values[target]:66 q['value'] = ''67 elif numeric_condition is False:68 q['value'] = ''69 responses_dict[step] = lst70 return responses_dict71def get_responses_from_session(request):72 return OrderedDict(sorted(request.session.items()))73def get_responses_from_session_grouped_by_steps(request):74 question_list = Question.objects.filter(key__in=question_step_mapping['prequalification'])75 lst = []76 for question in question_list:77 lst += [{'question__conditional_target': question.conditional_target,...
step_completeness.py
Source: step_completeness.py
1from django.urls import reverse2from edivorce.apps.core.models import Question3from edivorce.apps.core.utils.question_step_mapping import question_step_mapping, pre_qual_step_question_mapping4def evaluate_numeric_condition(target, reveal_response):5 """6 Tests whether the reveal_response contains a numeric condition. If so, it will7 evaluate the numeric condition and return the results of that comparison.8 :param target: the questions value being tested against9 :param reveal_response: the numeric condition that will be evaluated against10 :return: boolean result of numeric condition evaluation or None if there is no11 numeric condition to evaluate.12 """13 if target == '': # cannot evaluate if answer is blank14 return None15 if reveal_response.startswith('>='):16 return float(target) >= float(reveal_response[2:])17 elif reveal_response.startswith('<='):18 return float(target) <= float(reveal_response[2:])19 elif reveal_response.startswith('=='):20 return float(target) == float(reveal_response[2:])21 elif reveal_response.startswith('<'):22 return float(target) < float(reveal_response[1:])23 elif reveal_response.startswith('>'):24 return float(target) > float(reveal_response[1:])25 return None26def get_step_status(responses_by_step):27 status_dict = {}28 for step, lst in responses_by_step.items():29 if not lst:30 status_dict[step] = "Not started"31 else:32 if is_complete(step, lst)[0]:33 status_dict[step] = "Complete"34 else:35 status_dict[step] = "Started"36 return status_dict37def is_complete(step, lst):38 """39 Check required field of question for complete state40 Required: question is always require user response to be complete41 Conditional: Optional question needed depends on reveal_response value of conditional_target.42 """43 if not lst:44 return False, []45 question_list = Question.objects.filter(key__in=question_step_mapping[step])46 required_list = list(question_list.filter(required='Required').values_list("key", flat=True))47 conditional_list = list(question_list.filter(required='Conditional'))48 complete = True49 missing_responses = []50 for question_key in required_list:51 # everything in the required_list is required52 if not __has_value(question_key, lst):53 complete = False54 missing_responses += [question_key]55 for question in conditional_list:56 # find the response to the conditional target57 for target in lst:58 if target["question_id"] == question.conditional_target:59 if __condition_met(question.reveal_response, target, lst):60 # the condition was met then the question is required.61 # ... so check if it has a value62 if not __has_value(question.key, lst):63 complete = False64 missing_responses += [question.key]65 return complete, missing_responses66def get_formatted_incomplete_list(missed_question_keys):67 """68 Returns a list of dicts that contain the following information for the question69 that was not answered. Each dict contains the name of the question, as stored in70 the database, and the url of the page where the question is found.71 :param missed_question_keys:72 :return: list of dicts.73 """74 missed_questions = []75 for missed_question in Question.objects.filter(key__in=missed_question_keys):76 for step, questions in pre_qual_step_question_mapping.items():77 if missed_question.key in questions:78 missed_questions.append({79 'title': missed_question.name,80 'step_url': reverse('prequalification', kwargs={'step': step})81 })82 return missed_questions83def __condition_met(reveal_response, target, lst):84 # check whether using a numeric condition85 numeric_condition_met = evaluate_numeric_condition(target["value"], reveal_response)86 if numeric_condition_met is None:87 if target["value"] != reveal_response:88 return False89 elif numeric_condition_met is False:90 return False91 # return true if the target is not Conditional92 if target['question__required'] != 'Conditional':93 return True94 else:95 # if the target is Conditional and the condition was met, check the target next96 reveal_response = target["question__reveal_response"]97 conditional_target = target["question__conditional_target"]98 for new_target in lst:99 if new_target["question_id"] == conditional_target:...
rules.py
Source: rules.py
...42 ]43 else:44 return isinstance(45 subject_value, numbers.Number46 ) and evaluate_numeric_condition(subject_value, condition)47 return False48def evaluate_numeric_condition(subject_value: numbers.Number, condition: Condition):49 if condition.operator == OperatorType.GT:50 return subject_value > condition.value51 elif condition.operator == OperatorType.GTE:52 return subject_value >= condition.value53 elif condition.operator == OperatorType.LT:54 return subject_value < condition.value55 elif condition.operator == OperatorType.LTE:56 return subject_value <= condition.value...
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!!