def testGenerateNumberRange(self): levels = Levels(3) number = levels.generateNumber(5) self.assertEqual(type(number["floor"]), int) self.assertEqual(type(number["ceiling"]), int)
def testGenerateNumberValue(self): levels = Levels(3) number = levels.generateNumber(5) self.assertEqual(type(number["value"]), int) self.assertGreater(number["value"], 0) self.assertLess(number["value"], 100)
def testValidateAnswer(self): levels = Levels(5) levels.currentAnswer = lambda: {"value": 10} levels.previousAnswer = lambda: {"value": 11} self.assertTrue(levels.validateAnswer("l")) self.assertFalse(levels.validateAnswer("h"))
# Simple CLI based game for guessing a number being higher or lower # Requires Python > 3 # `python higher_or_lower.py` from classes.score_board import ScoreBoard from classes.player_score import PlayerScore from classes.levels import Levels from classes.game_controller import GameController score_board = ScoreBoard() score = PlayerScore() levels = Levels(15) game = GameController(score_board, score, levels) game.welcomeMessage() game.getName() game.runLevels() game.complete() game.leaders()
def testQuantity(self): levels = Levels(15) self.assertEqual(levels.quantity, 15)
def testGenerateAnswers(self): levels = Levels(10) answers = levels.generateAnswers() self.assertEqual(len(answers), 10)
def testRangeFor(self): levels = Levels(3) range = levels.rangeFor(2) self.assertEqual(range[1], 40)