def test_sorting_of_debts(dpp): debt_1 = debt.Debt("sorting of debts 1", 200, 20, 20) debt_2 = debt.Debt("sorting of debts 2", 300, 34, 30) debt_3 = debt.Debt("sorting of debts 3", 100, 10, 10) base_page = page.BasePage(dpp) main_page = base_page.open_main_page_as_guest() main_page.add_debt_parametrized(debt_1.debt_name, debt_1.starting_balance, debt_1.minimum_payment, debt_1.apr) main_page.add_debt_parametrized(debt_2.debt_name, debt_2.starting_balance, debt_2.minimum_payment, debt_2.apr) main_page.add_debt_parametrized(debt_3.debt_name, debt_3.starting_balance, debt_3.minimum_payment, debt_3.apr) main_page.set_payoff_order("APR high to low") main_page.check_step_details(0, debt_1.debt_name, debt_1.minimum_payment, (debt_1.number_of_payments - 2), 1) main_page.check_step_details(0, debt_2.debt_name, debt_2.minimum_payment, (debt_1.number_of_payments - 2), 0) main_page.check_step_details(0, debt_3.debt_name, debt_3.minimum_payment, (debt_1.number_of_payments - 2), 2) main_page.check_step_details(1, debt_1.debt_name, 20.60, 1, 1) main_page.check_step_details(1, debt_2.debt_name, 3.19, 1, 0) main_page.check_step_details(1, debt_3.debt_name, 4.86, 1, 2) debt_free = common.get_month_debt_free(11) debt_free_years_month = common.get_years_month_debt_free(debt_1.number_of_payments - 1) main_page.check_step_debt_paid_payoff_plan(0, debt_2.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(1, debt_1.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(2, debt_3.debt_name, debt_free, debt_free_years_month) main_page.set_payoff_order("Balance low to high") main_page.check_step_details(0, debt_1.debt_name, debt_1.minimum_payment, (debt_1.number_of_payments - 2), 1) main_page.check_step_details(0, debt_2.debt_name, debt_2.minimum_payment, (debt_1.number_of_payments - 2), 2) main_page.check_step_details(0, debt_3.debt_name, debt_3.minimum_payment, (debt_1.number_of_payments - 2), 0) main_page.check_step_details(1, debt_1.debt_name, 20.60, 1, 1) main_page.check_step_details(1, debt_2.debt_name, 3.19, 1, 2) main_page.check_step_details(1, debt_3.debt_name, 4.86, 1, 0) main_page.check_step_debt_paid_payoff_plan(2, debt_2.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(1, debt_1.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(0, debt_3.debt_name, debt_free, debt_free_years_month) main_page.set_payoff_order("As listed") main_page.check_step_details(0, debt_1.debt_name, debt_1.minimum_payment, (debt_1.number_of_payments - 2), 0) main_page.check_step_details(0, debt_2.debt_name, debt_2.minimum_payment, (debt_1.number_of_payments - 2), 1) main_page.check_step_details(0, debt_3.debt_name, debt_3.minimum_payment, (debt_1.number_of_payments - 2), 2) main_page.check_step_details(1, debt_1.debt_name, 20.60, 1, 0) main_page.check_step_details(1, debt_2.debt_name, 3.19, 1, 1) main_page.check_step_details(1, debt_3.debt_name, 4.86, 1, 2) main_page.check_step_debt_paid_payoff_plan(1, debt_2.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(0, debt_1.debt_name, debt_free, debt_free_years_month) main_page.check_step_debt_paid_payoff_plan(2, debt_3.debt_name, debt_free, debt_free_years_month)
def check_step_details(self, step_number, debt_name, minimum_payment, number_of_payments, index=None): payoff_plan_step = self.get_elements(MainPageLocators.payoff_plan_step)[step_number] step_duration = self.get_child_element(payoff_plan_step, MainPageLocators.payoff_plan_step_duration) payoff_plan_debts = self.get_child_elements(payoff_plan_step, MainPageLocators.payoff_plan_debt) if index == None: payoff_plan_debt = self.get_element_contains_text(payoff_plan_debts, debt_name) else: payoff_plan_debt = payoff_plan_debts[index] step_debt_name = self.get_child_element(payoff_plan_debt, MainPageLocators.payoff_plan_debt_name) step_payment = self.get_child_element(payoff_plan_debt, MainPageLocators.payoff_plan_payment) name = self.get_text(step_debt_name) payment = self.get_text(step_payment).replace("$", "") duration = self.get_text(step_duration) duration_expected = common.get_month_debt_free(number_of_payments) assert debt_name == name assert float(minimum_payment) == float(payment) assert duration_expected == duration