Beispiel #1
0
    def test_unique_vote_up(self):
        """
        A user vote on a deal should raise the temperature
        """

        #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()

        currentVotes = myDeal.temperature

        #Action
        voteOutput = myDeal.upvote(myUser.id)

        #Review
        self.assertEqual(voteOutput, True)
        self.assertEqual((currentVotes < myDeal.temperature), True)
Beispiel #2
0
 def test_unique_vote_up(self):
     """
     A user vote on a deal should raise the temperature
     """
     
     #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()
 
     currentVotes = myDeal.temperature
 
     #Action
     voteOutput = myDeal.upvote(myUser.id)
 
     #Review
     self.assertEqual(voteOutput, True)
     self.assertEqual((currentVotes < myDeal.temperature), True)
Beispiel #3
0
    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)
Beispiel #4
0
 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)