def testAdding_1_to_Two_Different_Targets_Returns_1_For_Each(self): score_keeper.addScore(1, 'target_1') score_keeper.addScore(1, 'target_2') scoreForTarget1 = score_keeper.getScoreForTarget('target_1') scoreForTarget2 = score_keeper.getScoreForTarget('target_2') self.assertEqual(scoreForTarget1, 1) self.assertEqual(scoreForTarget2, 1)
def testAdding_1_to_One_Target_And_2_to_A_Different_Target_Returns_Correct_Totals_For_Each(self): score_keeper.addScore(1, 'target_1') score_keeper.addScore(1, 'target_2') score_keeper.addScore(1, 'target_2') scoreForTarget1 = score_keeper.getScoreForTarget('target_1') scoreForTarget2 = score_keeper.getScoreForTarget('target_2') self.assertEqual(scoreForTarget1, 1) self.assertEqual(scoreForTarget2, 2)
def handleScores(): if (request.method == 'GET'): scores = {} scores["RED"] = score_keeper.getScoreForTarget("RED") scores["BLUE"] = score_keeper.getScoreForTarget("BLUE") return scores elif (request.method == 'DELETE'): score_keeper.clearAllScores() return 'success'
def handleTargetHit(eventMessage): if eventMessage.get('event_name') == 'target_hit': print("got a hit!!!!!!!!") targetId = eventMessage.get('target_id') score_keeper.addScore(1, targetId) print("Score for " + targetId + " =" + str(score_keeper.getScoreForTarget(targetId))) else: print("Not a target hit event")
def handleTimerEnd(): target_1 = score_keeper.getScoreForTarget('target_1') print("Got timer end message") message = "Final Score is " + str(target_1) + "." data = {"say": message + message, "parms": "-s 140 -ven-us+f3"} req = urllib2.Request('http://' + serverIP + ':5000/say') req.add_header('Content-Type', 'application/json') response = urllib2.urlopen(req, json.dumps(data))
def testAddingScoreWhenZeroReturns1(self): score_keeper.addScore(1, 'target_1') scoreForTarget1 = score_keeper.getScoreForTarget('target_1') self.assertEqual(scoreForTarget1, 1)
def testGetScoreForTargetNeverHitReturnsZero(self): value = score_keeper.getScoreForTarget("Notarealtarget") self.assertEqual(value, 0)
def testAdding_Score_With_2Hits_To_Same_Target_Returns_2(self): score_keeper.addScore(1, 'target_1') score_keeper.addScore(1, 'target_1') scoreForTarget1 = score_keeper.getScoreForTarget('target_1') self.assertEqual(scoreForTarget1, 2)