コード例 #1
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    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)
コード例 #2
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_aAdminReviewerTryingToReviewAsAdmin_ItShouldSucceedAndDeclareNonAgreeingConflictingReviewerAsCheaters(self):

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

        playerKey = Key.from_path('Player', playerId)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 0})

        createReviewerAndReview("test3", playerKey, {'score':999, 'time': 0})

        createReviewerAndReview("test4", playerKey, {'score':3, 'time': 0}, True)


        verifiedScore = VerifiedScore.get_by_key_name("verified", parent=playerKey)
        playerRecord = Record.get_by_key_name('record', parent=playerKey)

        self.assertTrue(verifiedScore is None or verifiedScore.value == 0)
        self.assertEqual(playerRecord.numCheat, 1)


        playerKey = Key.from_path('Player', 'test3')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)

        playerKey = Key.from_path('Player', 'test2')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 0)
コード例 #3
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    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)
コード例 #4
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    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)
コード例 #5
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_score_and_TwoDisapprovingButNonAgreeingReviewerAndOneApprovingReviewer_then_NonApprovingReviewerAreCheater_and_playerVerifiedScoreIsUpdated(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)
        createReviewerAndReview("test2", playerKey, {'score':99, 'time': 0})

        createReviewerAndReview("test3", playerKey, {'score':999, 'time': 0})

        createReviewerAndReview("test4", playerKey, {'score':3, 'time': 0})

        verifiedScoreWrapper = VerifiedScoreWrapper.get_by_key_name('verifiedScore', parent=playerKey)
        verifiedScore = verifiedScoreWrapper.verified
        self.assertEqual(verifiedScore.value, 3)

        playerKey = Key.from_path('Player', 'test2')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)

        playerKey = Key.from_path('Player', 'test3')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)
コード例 #6
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_score_and_ThreeDisapprovingReviewerOfWhichTwoAgree_then_NonAgreeingReviewerAndPLayerAreCheater(self):
        score = {'score' : 99, 'proof' : "sdsd", 'time' : 0}
        playerId = "test"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        playerKey = Key.from_path('Player', playerId)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 0})

        createReviewerAndReview("test3", playerKey, {'score':999, 'time': 0})

        createReviewerAndReview("test4", playerKey, {'score':3, 'time': 0})


        verifiedScore = VerifiedScore.get_by_key_name("verified", parent=playerKey)
        playerRecord = Record.get_by_key_name('record', parent=playerKey)

        self.assertTrue(verifiedScore is None or verifiedScore.value == 0)
        self.assertEqual(playerRecord.numCheat, 1)


        playerKey = Key.from_path('Player', 'test3')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)
コード例 #7
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_aScoreSubmitedTooEarly_ItShouldNotBeSubmited(self):
        score = {'score' : 3, 'proof' : "sdsd", 'time' : 10000}
        playerId = "test"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        playerKey = Key.from_path('Player', playerId)
        pendingScore = PendingScore.get_by_key_name('pendingScore', parent=playerKey)
        self.assertEqual(pendingScore, None)
コード例 #8
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_score_and_approvingReviewer_then_playerVerifiedScoreIsUpdated(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)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 0})

        verifiedScoreWrapper = VerifiedScoreWrapper.get_by_key_name('verifiedScore', parent=playerKey)
        verifiedScore = verifiedScoreWrapper.verified
        self.assertEqual(verifiedScore.value, score['score'])
コード例 #9
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_aAdminReviewerDisapprovingAnAlreadyVerifiedScore_ItShouldDeclareVerifierAsACheaterAndOtherAsNonCheaters(self):

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

        playerKey = Key.from_path('Player', playerId)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 0})

        createReviewerAndReview("test3", playerKey, {'score':999, 'time': 0})

        createReviewerAndReview("test4", playerKey, {'score':99, 'time': 0}) # verified


        verifiedScoreWrapper = VerifiedScoreWrapper.get_by_key_name('verifiedScore', parent=playerKey)
        verifiedScore = verifiedScoreWrapper.verified
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertTrue(verifiedScore.value == 99)
        self.assertEqual(playerRecord.numCheat, 0)

        createPlayer('admin1', 'admin1')
        admin = getAdmin()
        admin.playerList.append('admin1')
        setAdmin(admin)
        service.getHighestNonApprovedScore('admin1')

        service.approveScore('admin1', {'score':3, 'time': 0})


        verifiedScoreWrapper = VerifiedScoreWrapper.get_by_key_name('verifiedScore', parent=playerKey)
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertTrue(verifiedScoreWrapper is None)
        self.assertEqual(playerRecord.numCheat, 1)

        playerKey = Key.from_path('Player', 'test3')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 0)

        playerKey = Key.from_path('Player', 'test2')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 0)

        playerKey = Key.from_path('Player', 'test4')
        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)
コード例 #10
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    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'])
コード例 #11
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_goodScoreWithWrongTime_thenPlayerIsCheater(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)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 3})

        createReviewerAndReview("test3", playerKey, {'score':3, 'time': 3})

        verifiedScore = VerifiedScore.get_by_key_name("verified", parent=playerKey)
        self.assertTrue(verifiedScore is None or verifiedScore.value == 0)

        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)
コード例 #12
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_score_and_twoDisapprovingButAgreeingReviewers_then_playerIsCheater_and_verfiedScoreDoNotChange(self):
        score = {'score' : 99, 'proof' : "sdsd", 'time' : 0}
        playerId = "test"
        createPlayer(playerId, playerId)
        service.start(playerId)
        service.setScore(playerId, score)

        playerKey = Key.from_path('Player', playerId)

        createReviewerAndReview("test2", playerKey, {'score':3, 'time': 0})

        createReviewerAndReview("test3", playerKey, {'score':3, 'time': 0})

        verifiedScore = VerifiedScore.get_by_key_name("verified", parent=playerKey)
        self.assertTrue(verifiedScore is None or verifiedScore.value == 0)

        playerRecord = Record.get_by_key_name('record', parent=playerKey)
        self.assertEqual(playerRecord.numCheat, 1)
コード例 #13
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)
コード例 #14
0
ファイル: testScore.py プロジェクト: wighawag/ubh
    def test_given_aReviewerGettingRandomScoreQuickly_ItShouldNotBeAskedToRetryLater(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")
        response= service.getRandomScore("reviewer1")

        # TODO : expect a KeyError for retry
        self.assertFalse('result' in response and response['result']['retry']  > 0)