Пример #1
0
    def test_collect_normative_stances(self):
        """Verifies function returns only normative stances."""
        stance = Stance()
        stance.issue = "decision_analyze_test_norm"
        stance.side = outcomes.PRO

        agn_norm_stance = Stance()
        agn_norm_stance.issue = "decision_analyze_test_norm"
        agn_norm_stance.side = outcomes.CON

        result = stance_analyze.collect_normative_stances([stance, agn_norm_stance])
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0], stance)
Пример #2
0
    def test_remove_duplicates(self):
        """Verify only the intersection of the list is included."""
        stance = Stance()
        stance.issue = "Test"
        stance.side = outcomes.PRO

        stance2 = Stance()
        stance2.issue = "Something different"
        stance2.side = outcomes.PRO

        data = [stance, stance, stance2, stance2, stance, stance2, stance]
        result = util.remove_duplicates(data)

        self.assertEquals(len(result), 2)
        self.assertTrue(stance in result)
        self.assertTrue(stance2 in result)
Пример #3
0
    def test_difference(self):
        """Verify only the difference of the list is included."""
        stance = Stance()
        stance.issue = "Test"
        stance.side = outcomes.PRO

        stance2 = Stance()
        stance2.issue = "Test"
        stance2.side = outcomes.PRO

        stance3 = Stance()
        stance3.issue = "Test"
        stance3.side = outcomes.CON

        eq_fun = lambda stance1, stance2: stance1.match(stance2)
        result = util.difference([stance, stance2, stance3], [stance, stance2], eq_fun)
        self.assertEquals(result, [stance3])
Пример #4
0
    def test_normative_stance_norm_match(self):
        """Verifies function returns True when the stance matches the norm."""
        stance = Stance()
        stance.issue = "decision_analyze_test_norm"
        stance.side = outcomes.PRO

        result = stance_analyze.normative_stance(stance)
        self.assertTrue(result)
Пример #5
0
    def test_normative_stance_norm_doesnt_match(self):
        """Verifies function returns False when the stance does not match the norm."""
        stance = Stance()
        stance.issue = "decision_analyze_test_norm"
        stance.side = outcomes.CON

        result = stance_analyze.normative_stance(stance)
        self.assertFalse(result)
Пример #6
0
    def test_collect_normative_stances_no_result(self):
        """Verifies function return nothing if there are no normative stances."""
        agn_norm_stance = Stance()
        agn_norm_stance.issue = "decision_analyze_test_norm"
        agn_norm_stance.side = outcomes.CON

        result = stance_analyze.collect_normative_stances([agn_norm_stance, agn_norm_stance])
        self.assertEquals(len(result), 0)
    def test_run_fail(self):
        """ Verifies that run() doesn't modify the decision upon failure."""
        stance = Stance()
        stance.issue = "Something good"
        stance.side = outcomes.FOR

        stance1 = Stance()
        stance1.issue = "Something bad"
        stance1.side = outcomes.AGN

        self.decision.for_stances = [stance]
        self.decision.agn_stances = [stance1]
        result = self.strategy.run()

        self.assertFalse(result)
        self.assertFalse(self.strategy._success)
        self.assertEquals(self.decision.result, None)
        self.assertEquals(self.decision.reason, None)
Пример #8
0
    def generate_member_with_stances(self):
        member = Member()
        credo_stance = Stance()
        credo_stance.issue = "Credo"
        credo_stance.side = outcomes.PRO

        stances_stance = Stance()
        stances_stance.issue = "Stances"
        stances_stance.side = outcomes.CON

        pro_rel_stance = Stance()
        pro_rel_stance.issue = "Pro-Relation"
        pro_rel_stance.side = outcomes.PRO

        member.credo.append(credo_stance)
        member.stances.append(stances_stance)
        member.pro_rel_stances.append(pro_rel_stance)
        return member
Пример #9
0
    def test_collect_normative_stances_no_duplicates(self):
        """Verifies function return does not contain duplicates."""
        stance = Stance()
        stance.issue = "decision_analyze_test_norm"
        stance.side = outcomes.PRO

        result = stance_analyze.collect_normative_stances([stance, stance])
        self.assertEquals(len(result), 1)
        self.assertEquals(result[0], stance)
    def test_explain(self):
        """ Verifies explain runs if there is a success [aka _explain is implemented]."""
        stance = Stance()
        stance.issue = "Something good"
        stance.side = outcomes.FOR

        self.decision.for_stances = [stance]
        self.strategy.run()

        self.assertTrue(self.strategy._success)
        self.strategy.explain()
Пример #11
0
    def test_group_stances(self):
        """Verifies stances are grouped by stance and side."""
        stance1 = Stance()
        stance1.issue = "Apples"
        stance1.side = outcomes.PRO

        stance2 = Stance()
        stance2.issue = "Oranges"
        stance2.side = outcomes.PRO

        stance3 = Stance()
        stance3.issue = "Banana"
        stance3.side = outcomes.CON

        stance4 = Stance()
        stance4.issue = "Apples"
        stance4.side = outcomes.CON

        stance5 = Stance()
        stance5.issue = "Banana"
        stance5.side = outcomes.CON

        stance6 = Stance()
        stance6.issue = "Oranges"
        stance6.side = outcomes.CON

        input_list = [stance1, stance2, stance3, stance4, stance5, stance6]
        correct_list = [stance4, stance1, stance3, stance5, stance6, stance2]

        stance_analyze.group_stances(input_list)
        self.assertEquals(input_list, correct_list)
    def test_run_success_AGN(self):
        """ Verifies that run() successfully sets an AGN decision"""
        stance1 = Stance()
        stance1.issue = "Something bad"
        stance1.side = outcomes.AGN

        self.decision.agn_stances = [stance1]
        result = self.strategy.run()

        self.assertTrue(result)
        self.assertTrue(self.strategy._success)
        self.assertEquals(self.decision.result, outcomes.AGN)
        self.assertEquals(self.decision.reason, [stance1])
    def test_run_success_FOR(self):
        """ Verifies that run() successfully sets a FOR decision"""
        stance = Stance()
        stance.issue = "Something good"
        stance.side = outcomes.FOR

        self.decision.for_stances = [stance]
        result = self.strategy.run()

        self.assertTrue(result)
        self.assertTrue(self.strategy._success)
        self.assertEquals(self.decision.result, outcomes.FOR)
        self.assertEquals(self.decision.reason, [stance])
Пример #14
0
    def test__match_stances_helper_extra_stances(self):
        """ Verifies that extra stances in the filter stances list are not added."""
        member = self.generate_member_with_stances()
        stances = member.credo + member.pro_rel_stances

        stance = Stance()
        stance.issue = "Not Found"
        stance.side = outcomes.PRO
        stances.append(stance)

        result = member_analyze._match_stances_helper(member, stances)
        answer = member.credo + member.pro_rel_stances
        for entry in result:
            self.assertTrue(entry in answer)
Пример #15
0
    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)