def setUp(self):
        self.decision = Decision()
        self.member = Member()
        self.bill = Bill()
        self.strategy = NonPartisanDecisionStrategy(self.decision, self.member, self.bill)

        self.stance = Stance()
        self.stance.issue = "Some Issue"
        self.stance.side = outcomes.FOR

        self.stance1 = Stance()
        self.stance1.issue = "Some Other Issue"
        self.stance1.side = outcomes.AGN

        self.INDEPENDENT = "INDEPENDENT"
class NonPartisanDecisionStrategyTest(unittest.TestCase):
    """ Test suite for nonpartisan_decision_strategy.py."""

    def setUp(self):
        self.decision = Decision()
        self.member = Member()
        self.bill = Bill()
        self.strategy = NonPartisanDecisionStrategy(self.decision, self.member, self.bill)

        self.stance = Stance()
        self.stance.issue = "Some Issue"
        self.stance.side = outcomes.FOR

        self.stance1 = Stance()
        self.stance1.issue = "Some Other Issue"
        self.stance1.side = outcomes.AGN

        self.INDEPENDENT = "INDEPENDENT"

    def test_init(self):
        """Tests whether a strategy can be constructed properly"""
        result = NonPartisanDecisionStrategy(self.decision, self.member, self.bill)

        self.assertEqual(result._name, "Non-partisan Decision")
        self.assertEqual(result._decision, self.decision)
        self.assertEqual(result._member, self.member)
        self.assertEqual(result._bill, self.bill)
        self.assertEqual(result._success, False)

    def test_run_fail_no_credo(self):
        """ Verifies that run() fails if there is no MI_credo."""
        self.member.party = self.INDEPENDENT

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_agn = [self.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)

    def test_run_fail_no_party(self):
        """ Verifies that run() fails if there is no party."""

        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.FOR
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_agn = [self.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)

    def test_run_fail_no_opposing_groups(self):
        """ Verifies that run() fails if there is no groups opposing the member's credo."""

        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.FOR
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        result = self.strategy.run()
        self.assertFalse(result)
        self.assertFalse(self.strategy._success)
        self.assertEquals(self.decision.result, None)
        self.assertEquals(self.decision.reason, None)

    def test_run_fail_party_not_in_opposing_groups(self):
        """ Verifies that run() fails if the member's party does not have a
        stance in the groups opposing the member's credo."""

        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.FOR
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        self.decision.groups_agn = [self.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)

    def test_run_fail_credo_stance_not_most_importance(self):
        """ Verifies that run() fails if the member doesn't care too strongly
        about the credo stances."""

        self.stance.importance = importance.B

        credo_result = ResultData()
        credo_result.outcome = outcomes.FOR
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_agn = [self.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)


    def test_run_success_FOR(self):
        """ Verifies that run() successfully sets a FOR decision"""
        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.FOR
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_agn = [self.stance1]

        result = self.strategy.run()
        self.assertTrue(result)
        self.assertTrue(self.strategy._success)
        self.assertEquals(self.decision.result, outcomes.FOR)

    def test_run_success_AGN(self):
        """ Verifies that run() successfully sets an AGN decision"""
        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.AGN
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_for = [self.stance1]

        result = self.strategy.run()
        self.assertTrue(result)
        self.assertTrue(self.strategy._success)
        self.assertEquals(self.decision.result, outcomes.AGN)

    def test_explain(self):
        """ Verifies explain runs if there is a success [aka _explain is implemented]."""
        self.stance.importance = importance.A

        credo_result = ResultData()
        credo_result.outcome = outcomes.AGN
        credo_result.data = [self.stance]

        self.decision.MI_credo = credo_result
        self.member.party = self.INDEPENDENT

        self.stance1.source = self.INDEPENDENT
        self.decision.groups_for = [self.stance1]

        result = self.strategy.run()
        self.assertTrue(result)
        self.strategy.explain()