Пример #1
0
    def test_vote_all_member_and_bill_specified(self):
        """ Verifies vote_all for a particular member on a particular bill"""
        strategy_hash.STRATEGY_HASH = {"AlwaysFail": AlwaysFailStrategy,
                                       "AlwaysFail2" : AlwaysFailStrategy,
                                       "AlwaysSucceed": AlwaysSucceedStrategy}
        vote.vote_all(member_identifier=self.MEMBER, bill_identifier=self.BILL2)

        decision_count = self.DB.DB[db_constants.DECISIONS].count()
        self.assertEquals(1, decision_count)

        member = self.DB.find_one(db_constants.MEMBERS, {"full_name" : self.MEMBER})
        bill = self.DB.find_one(db_constants.BILLS, {"name": self.BILL2})
        decision = self.DB.find_one(db_constants.DECISIONS, {"member":member._id})

        self.assertEquals(decision.member, member._id)
        self.assertEquals(decision.bill, bill._id)
Пример #2
0
    def test_vote_all_member_specified(self):
        """ Verifies vote_all when voting for one member on all bills."""
        strategy_hash.STRATEGY_HASH = {"AlwaysFail": AlwaysFailStrategy,
                                       "AlwaysFail2" : AlwaysFailStrategy,
                                       "AlwaysSucceed": AlwaysSucceedStrategy}
        vote.vote_all(member_identifier=self.MEMBER)

        bill_count = self.DB.DB[db_constants.BILLS].count()
        decision_count = self.DB.DB[db_constants.DECISIONS].count()

        self.assertEquals(bill_count, decision_count)

        member = self.DB.find_one(db_constants.MEMBERS, {"full_name" : self.MEMBER})
        vote_cursor = self.DB.find(db_constants.DECISIONS, {"member":member._id})
        self.assertEquals(bill_count, vote_cursor.cursor.count())

        for bill in self.DB.find(db_constants.BILLS):
            vote_cursor = self.DB.find(db_constants.DECISIONS,
                {"bill":bill._id})
            self.assertEquals(1, vote_cursor.cursor.count())
Пример #3
0
    def test_vote_all_bill_specified(self):
        """ Verifies vote_all for all members on a given bill."""
        strategy_hash.STRATEGY_HASH = {"AlwaysFail": AlwaysFailStrategy,
                                       "AlwaysFail2" : AlwaysFailStrategy,
                                       "AlwaysSucceed": AlwaysSucceedStrategy}
        vote.vote_all(bill_identifier=self.BILL2)

        member_count = self.DB.DB[db_constants.MEMBERS].count()
        decision_count = self.DB.DB[db_constants.DECISIONS].count()

        # Make sure there is a decision for every member on every vote.
        self.assertEquals(member_count, decision_count)

        for member in self.DB.find(db_constants.MEMBERS):
            vote_cursor = self.DB.find(db_constants.DECISIONS,
                {"member":member._id})
            self.assertEquals(1, vote_cursor.cursor.count())

        bill = self.DB.find_one(db_constants.BILLS, {"name": self.BILL2})
        vote_cursor = self.DB.find(db_constants.DECISIONS, {"bill":bill._id})
        self.assertEquals(member_count, vote_cursor.cursor.count())
Пример #4
0
    def test_vote_all(self):
        """ Verifies vote_all for all members on all bills."""
        strategy_hash.STRATEGY_HASH = {"AlwaysFail": AlwaysFailStrategy,
                                       "AlwaysFail2" : AlwaysFailStrategy,
                                       "AlwaysSucceed": AlwaysSucceedStrategy}
        vote.vote_all()

        member_count = self.DB.DB[db_constants.MEMBERS].count()
        bill_count = self.DB.DB[db_constants.BILLS].count()
        decision_count = self.DB.DB[db_constants.DECISIONS].count()

        # Make sure there is a decision for every member on every vote.
        self.assertEquals(member_count * bill_count, decision_count)

        for member in self.DB.find(db_constants.MEMBERS):
            vote_cursor = self.DB.find(db_constants.DECISIONS,
                {"member":member._id})
            self.assertEquals(bill_count, vote_cursor.cursor.count())

        for bill in self.DB.find(db_constants.BILLS):
            vote_cursor = self.DB.find(db_constants.DECISIONS, {"bill":bill._id})
            self.assertEquals(member_count, vote_cursor.cursor.count())