Beispiel #1
0
    def testGenerateNumberRange(self):
        levels = Levels(3)

        number = levels.generateNumber(5)

        self.assertEqual(type(number["floor"]), int)
        self.assertEqual(type(number["ceiling"]), int)
Beispiel #2
0
    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)
Beispiel #3
0
    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"))
Beispiel #4
0
# 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()
Beispiel #5
0
    def testQuantity(self):
        levels = Levels(15)

        self.assertEqual(levels.quantity, 15)
Beispiel #6
0
    def testGenerateAnswers(self):
        levels = Levels(10)

        answers = levels.generateAnswers()

        self.assertEqual(len(answers), 10)
Beispiel #7
0
    def testRangeFor(self):
        levels = Levels(3)

        range = levels.rangeFor(2)
        self.assertEqual(range[1], 40)