Exemplo n.º 1
0
    def test_json(self):
        vote = VotableArtifact()
        assert vote.__json__() == {'votes_up': 0, 'votes_down': 0}

        vote.vote_down(self.user1)
        assert vote.__json__() == {'votes_up': 0, 'votes_down': 1}

        vote.vote_up(self.user2)
        assert vote.__json__() == {'votes_up': 1, 'votes_down': 1}
Exemplo n.º 2
0
    def test_json(self):
        vote = VotableArtifact()
        assert vote.__json__() == {'votes_up': 0, 'votes_down': 0}

        vote.vote_down(self.user1)
        assert vote.__json__() == {'votes_up': 0, 'votes_down': 1}

        vote.vote_up(self.user2)
        assert vote.__json__() == {'votes_up': 1, 'votes_down': 1}
Exemplo n.º 3
0
    def test_change_vote(self):
        vote = VotableArtifact()

        vote.vote_up(self.user1)
        vote.vote_down(self.user1)

        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user1.username]
        assert vote.votes_up == 0
        assert len(vote.votes_up_users) == 0
Exemplo n.º 4
0
    def test_change_vote(self):
        vote = VotableArtifact()

        vote.vote_up(self.user1)
        vote.vote_down(self.user1)

        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user1.username]
        assert vote.votes_up == 0
        assert len(vote.votes_up_users) == 0
Exemplo n.º 5
0
    def test_vote_down(self):
        vote = VotableArtifact()

        vote.vote_down(self.user1)
        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user1.username]

        vote.vote_down(self.user2)
        assert vote.votes_down == 2
        assert vote.votes_down_users == [self.user1.username,
                                        self.user2.username]

        vote.vote_down(self.user1)  # unvote user1
        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user2.username]

        assert vote.votes_up == 0, 'vote_up must be 0 if we voted down only'
        assert len(vote.votes_up_users) == 0
Exemplo n.º 6
0
    def test_vote_down(self):
        vote = VotableArtifact()

        vote.vote_down(self.user1)
        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user1.username]

        vote.vote_down(self.user2)
        assert vote.votes_down == 2
        assert vote.votes_down_users == [self.user1.username,
                                        self.user2.username]

        vote.vote_down(self.user1)  # unvote user1
        assert vote.votes_down == 1
        assert vote.votes_down_users == [self.user2.username]

        assert vote.votes_up == 0, 'vote_up must be 0 if we voted down only'
        assert len(vote.votes_up_users) == 0