def test_sort_stances_key_given(self): """Verifies sort when the member key is defined.""" stances = self.generate_stance_array() member = Member() member.stance_sort_key = stance_sort_key.LOYALTY stance_analyze.sort_stances(stances, member) for i in range(0, len(stances) - 1): self.assertEqual(stances[i]._sort_key, stance_sort_key.LOYALTY) self.assertTrue(stances[i].sort_key >= stances[i + 1].sort_key)
def test_match_stances_agn(self): """ Verifies the returned stances are sorted by importance.""" member = Member() member.stance_sort_key = stance_sort_key.EQUITY credo_stance = Stance() credo_stance.issue = "Credo" credo_stance.side = outcomes.PRO credo_stance.importance = importance.B stances_stance1 = Stance() stances_stance1.issue = "Stances" stances_stance1.side = outcomes.CON stances_stance1.importance = importance.D stances_stance2 = Stance() stances_stance2.issue = "An Outcomes" stances_stance2.side = outcomes.PRO stances_stance2.importance = importance.A pro_rel_stance = Stance() pro_rel_stance.issue = "Pro-Relation" pro_rel_stance.side = outcomes.PRO pro_rel_stance.importance = importance.C member.credo.append(credo_stance) member.stances.append(stances_stance1) member.stances.append(stances_stance2) member.pro_rel_stances.append(pro_rel_stance) bill = Bill() bill.stances_for = member.credo + member.stances bill.stances_agn = member.pro_rel_stances result = member_analyze.match_stances(member, bill, outcomes.FOR) sorted_answer = [stances_stance2, credo_stance, stances_stance1] self.assertEqual(result, sorted_answer)