def check_pop_ratio_of_ratios_validation(self, factor_type, operator_type, threshold_value, result): CheckMessagesContributorDetails( ).check_if_overall_validation_triggered() is_validation_triggered = False if factor_type == 'increase': value_one = int(cp_internet_sales) * int(pp_total_sales) value_two = int(cp_total_sales) * int(pp_internet_sales) is_validation_triggered = ReportingHelper.compare_the_values_with_operator( operator_type, value_one, int(threshold_value) * value_two) elif factor_type == 'decrease': value_one = int(cp_total_sales) * int(pp_internet_sales) value_two = int(cp_internet_sales) * int(pp_total_sales) is_validation_triggered = ReportingHelper.compare_the_values_with_operator( operator_type, value_one, int(threshold_value) * value_two) elif factor_type == 'not-applicable': is_validation_triggered = 'false' ReportingHelper.check_single_message_matches( 'Q21', result, str(is_validation_triggered).lower())
def run_the_validation_process(self, total_turnover_value, exp_derived_value): SeleniumCore.set_current_data_text( self.QUESTION_TOTAL_TURNOVER_ELEMENT, total_turnover_value) CheckValuesContributorDetails().save_the_application() actual_derived_val = SeleniumCore.get_attribute_element_text( *RsiContributorDetailsPage.QUESTION_DERIVED_ELEMENT) ReportingHelper.check_single_message_matches('Q7034', actual_derived_val, exp_derived_value)
def run_the_validation_process(self, threshold_primary_value, exp_derived_value): SeleniumCore.set_current_data_text( details.THRESHOLD_PRIMARY_QUESTION_ELEMENT, threshold_primary_value) CheckValuesContributorDetails().save_the_application() actual_derived_val = SeleniumCore.get_attribute_element_text( By.ID, details.THRESHOLD_DERIVED_QUESTION_ELEMENT) ReportingHelper.check_single_message_matches('Q12', actual_derived_val, exp_derived_value)
def check_historic_data_back_periods(self, periods): table = self.driver.find_element_by_id("tabId2") rows = table.find_elements_by_tag_name("tr") periods = self.sort_periods_order(periods) for i in range(0, 1): cols = rows[i].find_elements_by_tag_name("th") count = 1 for period in periods: ReportingHelper.check_single_message_matches( 'Question', cols[count].text, period) count += 1
def run_the_validation_process(self, questions): questions_list = questions[0] comparing_question_value = Utilities.convert_blank_data_value(questions[1]) derived_question_value = Utilities.convert_blank_data_value(questions[2]) survey = Utilities.convert_blank_data_value(questions[3]) comparing_question_element = Utilities.get_question_code_element(survey, questions_list[0]) derived_question_element = Utilities.get_question_code_element(survey, questions_list[1]) SeleniumCore.set_current_data_text(comparing_question_element, comparing_question_value) CheckValuesContributorDetails().save_the_application() actual_derived_val = SeleniumCore.get_attribute_element_text(By.ID, derived_question_element) if derived_question_value == '': derived_question_value = '0' ReportingHelper.check_single_message_matches(questions_list[1], actual_derived_val, derived_question_value)
def check_multiple_comment_text_messages(self, question_codes): survey = question_codes[0] questions_list = question_codes[1] commodity_values = Utilities.get_values_as_a_list(question_codes[2]) if len(questions_list) > 1: count = 0 for question in questions_list: question_element = Utilities.get_question_code_element( survey, question) question_actual_text = SeleniumCore.get_attribute_element_text( By.ID, question_element) commodity_value = Utilities.convert_blank_data_value( commodity_values[count]) ReportingHelper.check_single_message_matches( question_element, question_actual_text, commodity_value)
def select_the_form_row(self, reference, period, sic_code): table = SeleniumCore.wait_for_element_to_be_displayed( By.ID, "ResultsTable") rows = table.find_elements_by_tag_name("tr") # Ignore the first row for i in range(1, len(rows)): cols = rows[i].find_elements_by_tag_name("td") # Check to see the sic code exists if sic_code: ReportingHelper.check_single_message_matches( reference, cols[i + 6].text, sic_code) # Check to see if any references appear that shouldn't be there if cols[1].text == reference and cols[2].text == period: view_form = rows[i].find_elements_by_tag_name("button") SeleniumCore.select_view_form(view_form[0]) break
def check_values_are_not_equal(self, question, comparison_val_one, comparison_val_two, result): CheckMessagesContributorDetails( ).check_if_overall_validation_triggered() if comparison_val_one == 'blank' and comparison_val_two == 'blank': comparison_val_one = Utilities.convert_blank_data_value( comparison_val_one) comparison_val_two = Utilities.convert_blank_data_value( comparison_val_two) is_validation_exists = ReportingHelper.compare_strings( comparison_val_one, comparison_val_two) else: is_validation_exists = ReportingHelper.compare_values_are_not_equal( comparison_val_one, comparison_val_two) ReportingHelper.check_single_message_matches( question, result, str(is_validation_exists).lower())
def check_adjusted_responses(self, *responses): self.actual_response_values = Utilities.get_values_as_a_list( responses[1]) self.expected_response_type = Utilities.get_values_as_a_list( responses[2])[0] total_turnover = self.get_adjusted_response( contributor_details.TOTAL_TURNOVER_QUESTION_ELEMENT) internet_sales = self.get_adjusted_response( contributor_details.INTERNET_SALES_QUESTION_ELEMENT) t_turnover = self.compare_values(total_turnover, 0) i_sales = self.compare_values(internet_sales, 1) ReportingHelper.check_single_message_matches( contributor_details.TOTAL_TURNOVER_QUESTION_ELEMENT, t_turnover, self.expected_response_type) ReportingHelper.check_single_message_matches( contributor_details.INTERNET_SALES_QUESTION_ELEMENT, i_sales, self.expected_response_type)
def check_values_movement_to_or_from_zero(self, question_codes, comparison_val_one, comparison_val_two, result): CheckMessagesContributorDetails( ).check_if_overall_validation_triggered() if len(question_codes) > 1: for question in question_codes: if comparison_val_one == 'blank' and comparison_val_two == 'blank': value_one = Utilities.convert_blank_data_value( comparison_val_one) value_two = Utilities.convert_blank_data_value( comparison_val_two) is_validation_exists = ReportingHelper.compare_strings( value_one, value_two) else: is_validation_exists = ReportingHelper.compare_the_zero_movement_values( comparison_val_one, comparison_val_two) ReportingHelper.check_single_message_matches( question, result, str(is_validation_exists).lower())