def test_guess_not_in_correct(self):
     user=get_user('lee_test')
     guesses=create_game(user.id)[1]
     guess=guesses.answer[0]
     update_guesses(guess, guesses)
     self.assertEqual(validate_guess(guess, guesses), 
         '"{}" already guessed. Please guess a new letter.'.format(guess))
 def test_correct_guess_replace(self):
     user = get_user('lee_test')
     guesses = create_game(user.id)[1]
     guess = guesses.answer[0]
     update_guesses(guess, guesses)
     self.assertTrue(any(char.isalpha()
                         for char in guesses.correct_guesses))
 def test_guess_not_in_correct(self):
     user = get_user('lee_test')
     guesses = create_game(user.id)[1]
     guess = guesses.answer[0]
     update_guesses(guess, guesses)
     self.assertEqual(
         validate_guess(guess, guesses),
         '"{}" already guessed. Please guess a new letter.'.format(guess))
Ejemplo n.º 4
0
 def test_incorrect_guess_does_not_display(self):
     user=get_user('lee_test')
     guesses=create_game(user.id)[1]
     for letter in alphabet:
         if not letter in guesses.answer:
             guess=letter
             break
     update_guesses(guess, guesses)
     self.assertFalse(any(char.isalpha() for char in guesses.correct_guesses))
Ejemplo n.º 5
0
    def test_win_status(self):
        user=get_user('lee_test')
        user_initial_wins=user.wins
        guesses=create_game(user.id)[1]
        for letter in guesses.answer:
            update_guesses(letter, guesses)
        update_game(guesses)

        self.assertEqual(guesses.game.status, 'win')
        self.assertGreater(user.wins, user_initial_wins)
    def test_update_game_win(self):
        user = get_user('lee_test')
        user_initial_wins = user.wins
        guesses = create_game(user.id)[1]
        for letter in guesses.answer:
            update_guesses(letter, guesses)
        update_game(guesses)

        self.assertEqual(guesses.game.status, 'win')
        self.assertGreater(user.wins, user_initial_wins)
 def test_incorrect_guess_without_replace(self):
     user = get_user('lee_test')
     guesses = create_game(user.id)[1]
     for letter in alphabet:
         if not letter in guesses.answer:
             guess = letter
             break
     update_guesses(guess, guesses)
     self.assertFalse(
         any(char.isalpha() for char in guesses.correct_guesses))
    def test_guess_not_in_incorrect(self):
        user=get_user('lee_test')
        guesses=create_game(user.id)[1]
        for letter in alphabet:
            if not letter in guesses.answer:
                guess=letter 
                break

        update_guesses(guess, guesses)
        self.assertEqual(validate_guess(guess, guesses), 
            '"{}" already guessed. Please guess a new letter.'.format(guess))
Ejemplo n.º 9
0
    def test_answer_cheat(self):
        user=get_user('lee_test')
        game, guesses=create_game(user.id)
        update_guesses("a", guesses)
        update_answer("h", game)

        self.assertEqual(game.answer, "h")
        self.assertEqual(guesses.answer, "h")
        self.assertEqual(guesses.correct_guesses, '___')
        self.assertEqual(guesses.incorrect_guesses, '')
        self.assertEqual(guesses.remaining_guesses, 1)
    def test_game_check_win(self):
        user = get_user('lee_test')
        guesses = create_game(user.id)[1]
        for letter in guesses.answer:
            update_guesses(letter, guesses)
        self.assertTrue(check_game(guesses))

        user = get_user('lee_test')
        guesses = create_game(user.id)[1]
        letter = guesses.answer[0]
        update_guesses(letter, guesses)
        self.assertFalse(check_game(guesses))
    def test_guess_not_in_incorrect(self):
        user = get_user('lee_test')
        guesses = create_game(user.id)[1]
        for letter in alphabet:
            if not letter in guesses.answer:
                guess = letter
                break

        update_guesses(guess, guesses)
        self.assertEqual(
            validate_guess(guess, guesses),
            '"{}" already guessed. Please guess a new letter.'.format(guess))
    def test_game_check_win(self):
        user=get_user('lee_test')
        guesses=create_game(user.id)[1]
        for letter in guesses.answer:
            update_guesses(letter, guesses)
        self.assertTrue(check_game(guesses)) 

        user=get_user('lee_test')
        guesses=create_game(user.id)[1]
        letter=guesses.answer[0]
        update_guesses(letter, guesses)
        self.assertFalse(check_game(guesses)) 
 def test_game_check_loss(self):
     user = get_user('lee_test')
     guesses = create_game(user.id)[1]
     alphabet_i = 0
     answer_i = 0
     while len(guesses.answer) > answer_i:
         if guesses.answer[answer_i] != alphabet[alphabet_i]:
             update_guesses(alphabet[alphabet_i], guesses)
             answer_i += 1
             alphabet_i += 1
         else:
             alphabet_i += 1
     self.assertTrue(check_game(guesses))
 def test_game_check_loss(self):
     user=get_user('lee_test')
     guesses=create_game(user.id)[1]
     alphabet_i = 0
     answer_i = 0
     while len(guesses.answer) > answer_i:
         if guesses.answer[answer_i] != alphabet[alphabet_i]:
             update_guesses(alphabet[alphabet_i], guesses)
             answer_i += 1
             alphabet_i += 1
         else:
             alphabet_i += 1
     self.assertTrue(check_game(guesses))
Ejemplo n.º 15
0
    def test_correct_guess_does_not_decrement_remaining_guesses(self):
        user=get_user('lee_test')
        guesses=create_game(user.id)[1]
        guess=guesses.answer[0]
        update_guesses(guess, guesses)
        self.assertEqual(guesses.remaining_guesses, len(guesses.answer))

        user=get_user('lee_test')
        guesses=create_game(user.id)[1]
        for letter in alphabet:
            if letter in guesses.answer:
                guess=letter
                break
        update_guesses(guess, guesses)
        self.assertEqual(guesses.remaining_guesses, len(guesses.answer))
    def test_remaining_guess_decrement(self):
        user = get_user('lee_test')
        guesses = create_game(user.id)[1]
        guess = guesses.answer[0]
        update_guesses(guess, guesses)
        self.assertEqual(guesses.remaining_guesses, len(guesses.answer) - 1)

        user = get_user('lee_test')
        guesses = create_game(user.id)[1]
        for letter in alphabet:
            if not letter in guesses.answer:
                guess = letter
                break
        update_guesses(guess, guesses)
        self.assertEqual(guesses.remaining_guesses, len(guesses.answer) - 1)
    def test_update_game_loss(self):
        user = get_user('lee_test')
        user_initial_loses = user.loses
        guesses = create_game(user.id)[1]
        alphabet_i = 0
        answer_i = 0
        while len(guesses.answer) > answer_i:
            if guesses.answer[answer_i] != alphabet[alphabet_i]:
                update_guesses(alphabet[alphabet_i], guesses)
                answer_i += 1
            else:
                alphabet_i += 1
        update_game(guesses)

        self.assertEqual(guesses.game.status, 'loss')
        self.assertGreater(user.loses, user_initial_loses)
    def test_update_game_loss(self):
        user=get_user('lee_test')
        user_initial_loses=user.loses
        guesses=create_game(user.id)[1]
        alphabet_i = 0
        answer_i = 0
        while len(guesses.answer) > answer_i:
            if guesses.answer[answer_i] != alphabet[alphabet_i]:
                update_guesses(alphabet[alphabet_i], guesses)
                answer_i += 1
            else:
                alphabet_i += 1
        update_game(guesses)

        self.assertEqual(guesses.game.status, 'loss')
        self.assertGreater(user.loses, user_initial_loses)
Ejemplo n.º 19
0
 def test_correct_guess_displays(self):
     user=get_user('lee_test')
     guesses=create_game(user.id)[1]
     guess=guesses.answer[0]
     update_guesses(guess, guesses)
     self.assertTrue(any(char.isalpha() for char in guesses.correct_guesses))