Ejemplo n.º 1
0
def check():
    game = Game(session['score'])
    game.grid = list(request.form['grid'])
    word = request.form['word']
    is_valid = game.is_valid(word)
    if is_valid:
        session['score']+=game.CurrScore()

    return render_template('check.html', is_valid=is_valid, curr_score=game.CurrScore(), score=session['score'], grid=game.grid, word=word)
Ejemplo n.º 2
0
    def test_unknown_word_is_invalid(self):
        new_game = Game()
        new_game.grid = list('KWIENFUQW')  # Force the grid to a test case:
        self.assertIs(new_game.is_valid('FEUN'), False)

        self.assertIs(new_game.CurrScore(), 0)
        self.assertIs(new_game.Score(), 0)
Ejemplo n.º 3
0
    def test_game_initialization(self):
        new_game = Game()
        grid = new_game.grid
        self.assertIsInstance(grid, list)
        self.assertEqual(len(grid), 9)
        for letter in grid:
            self.assertIn(letter, string.ascii_uppercase)

        self.assertIs(new_game.CurrScore(),
                      0)  # check won score in current game
        self.assertIs(new_game.Score(), 0)  # check total score
Ejemplo n.º 4
0
    def test_is_invalid(self):
        new_game = Game()
        new_game.grid = list('KWEUEAKRZ')  # Force the grid to a test case:
        self.assertIs(new_game.is_valid('SANDWICH'), False)

        self.assertIs(new_game.CurrScore(), 0)
        self.assertIs(new_game.Score(), 0)

        self.assertEqual(
            new_game.grid,
            list('KWEUEAKRZ'))  # Make sure the grid remained untouched
Ejemplo n.º 5
0
    def test_is_valid(self):
        new_game = Game()
        new_game.grid = list('KWEUEAKRZ')  # Force the grid to a test case:
        self.assertIs(new_game.is_valid('EUREKA'), True)
        self.assertEqual(
            new_game.grid,
            list('KWEUEAKRZ'))  # Make sure the grid remained untouched

        self.assertIs(new_game.CurrScore(), 6)
        self.assertIs(new_game.Score(),
                      0)  # total score is only updated in wsgi
Ejemplo n.º 6
0
    def test_empty_word_is_invalid(self):
        new_game = Game()
        self.assertIs(new_game.is_valid(''), False)

        self.assertIs(new_game.CurrScore(), 0)
        self.assertIs(new_game.Score(), 0)