Пример #1
0
    def test_given_aReviewerReviewingTwoTimesTooQuickly_ItShouldBeAskedToRetryLater(self):

        setReviewTimeUnit(2000)
        score = {'score' : 3, 'proof' : "sdsd", 'time' : 0}
        playerId = "test1"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        score = {'score' : 3, 'proof' : "sdsd", 'time' : 0}
        playerId = "test2"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        createPlayer("reviewer1", "reviewer1")

        sleep(3)

        service.getRandomScore("reviewer1")
        service.reviewScore("reviewer1", {'score':3, 'time': 0})

        response= service.getRandomScore("reviewer1")

        self.assertTrue('result' in response and response['result']['retry']  > 0)
Пример #2
0
    def test_given_reviewerVerifyingScore_if_playerSetNewScoreInTheMeanTime_when_reviewerSetReviewItShouldBeDiscarded(self):
        score = {'score' : 3, 'proof' : "sdsd", 'time' : 0}
        playerId = "test"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        playerKey = Key.from_path('Player', playerId)
        reviewer = createPlayer("reviewer", "reviewer")
        assignScoreReview(reviewer, playerKey)


        reviewer2 = createPlayer("reviewer2", "reviewer2")
        scoreToReview = assignScoreReview(reviewer2, playerKey)

        score = {'score' : 4, 'proof' : "sdsd", 'time' : 0}
        service.start(playerId)
        service.setScore(playerId, score)

        service.reviewScore("reviewer", {'score':4, 'time': 0})
        service.reviewScore("reviewer2", {'score':3, 'time': 0})

        verifiedScore = VerifiedScore.get_by_key_name("verified", parent=playerKey)
        self.assertEqual(verifiedScore, None)

        # TDO : move to another test?
        scoreToReview = db.get(scoreToReview.key())
        self.assertEqual(scoreToReview, None)
Пример #3
0
def createReviewerAndReview(reviewerId, playerKey, scoreValue, adminMode = False):
    reviewer = createPlayer(reviewerId, reviewerId)
    if adminMode:
        admin = getAdmin()
        admin.playerList.append(reviewerId)
        setAdmin(admin)
    scoreToReview = assignScoreReview(reviewer, playerKey)
    service.reviewScore(reviewerId, scoreValue, adminMode)
    return scoreToReview
Пример #4
0
    def test_given_aAdminReviewerTryingToReviewAsAdmin_ItShouldSucceed(self):

        setReviewTimeUnit(0)
        score = {'score' : 3, 'proof' : "sdsd", 'time' : 0}
        playerId = "test1"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        createPlayer("reviewer1", "reviewer1")

        admin = getAdmin()
        admin.playerList.append('reviewer1')
        setAdmin(admin)

        service.getRandomScore("reviewer1")
        response = service.reviewScore("reviewer1", {'score':3, 'time': 0}, True)


        self.assertTrue('result' in response)

        playerKey = Key.from_path('Player', playerId)
        verifiedScoreWrapper = VerifiedScoreWrapper.get_by_key_name('verifiedScore', parent=playerKey)
        verifiedScore = verifiedScoreWrapper.verified
        self.assertEqual(verifiedScore.value, 3)
        self.assertEqual(verifiedScore.approvedByAdmin, True)
Пример #5
0
    def test_whetherTimeUnitIsUpdatedProperly(self):
        setReviewTimeUnit(0)
        for i in range(0,10):
            playerId = 'test' + str(i)
            createPlayer(playerId, playerId)
            service.start(playerId)
            service.setScore(playerId, {'score' : 3, 'proof' : "sdsd", 'time' : 0})

        for i in range(10,20):
            playerId = 'test' + str(i)
            createPlayer(playerId, playerId)
            service.getRandomScore(playerId)
            service.reviewScore(playerId, {'score' : 3, 'time' : 0})

        config.nbPlayerPerTimeUnit = 10
        setCurrentUser('*****@*****.**', 'test', True)
        response = self.updateReviewTimeUnitApp.get('/cron/updateReviewTimeUnit')
        responseValue = int(response.body)
        self.assertTrue(responseValue > 0 and responseValue < 10000)
Пример #6
0
    def test_given_aReviewerTryingToReviewAsAdmin_ItShouldBeGivenAnError(self):

        setReviewTimeUnit(0)
        score = {'score' : 3, 'proof' : "sdsd", 'time' : 0}
        playerId = "test1"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        createPlayer("reviewer1", "reviewer1")

        service.getRandomScore("reviewer1")
        response = service.reviewScore("reviewer1", {'score':3, 'time': 0}, True)

        self.assertTrue('error' in response and response['error']['code'] == ADMIN_ONLY['code'])