def test_unvote_vote_up(self): """ If a user that has upvoted a deal downvotes it, he should be able to vote again """ #Preparation myDeal = Deal() myDeal.title_text = "This is a fake product only for testing purposes" myDeal.link_url = "http://www.amazon.com" myDeal.vendor_text = "Amazon" myDeal.price_decimal = 10.3 myDeal.description_text = "Lorem Ipsum Dolor sit amet esperum funcionorum perfectunum" myDeal.imageUrl_url = "http://www.amazon.com" myDeal.save() myUser = User() myUser.username = "******" myUser.save() myProfile = Profile() myProfile.user = myUser myProfile.save() myDeal.upvote(myUser.id) myDeal.downvote(myUser.id) currentVotes = myDeal.temperature #Action voteOutput = myDeal.upvote(myUser) #Review self.assertEqual(voteOutput, True) self.assertEqual((currentVotes < myDeal.temperature), True)
def test_repeated_vote_up(self): """ A user should be able to vote up, only if he has never voted before on the same article """ #Preparation myDeal = Deal() myDeal.title_text = "This is a fake product only for testing purposes" myDeal.link_url = "http://www.amazon.com" myDeal.vendor_text = "Amazon" myDeal.price_decimal = 10.3 myDeal.description_text = "Lorem Ipsum Dolor sit amet esperum funcionorum perfectunum" myDeal.imageUrl_url = "http://www.amazon.com" myDeal.save() myUser = User() myUser.username = "******" myUser.save() myProfile = Profile() myProfile.user = myUser myProfile.save() myDeal.upvote(myUser.id) currentVotes = myDeal.temperature #Action voteOutput = myDeal.upvote(myUser) #Review self.assertEqual(voteOutput, False) self.assertEqual(currentVotes, myDeal.temperature)