コード例 #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)
コード例 #2
0
ファイル: tests.py プロジェクト: d00astro/Krokodeal
 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)
コード例 #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)
コード例 #4
0
ファイル: tests.py プロジェクト: d00astro/Krokodeal
 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)