def test_win(self): word_list = [] game = start_new_game(word_list, 'cat') guess_letter(game, 'c') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'a') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'b') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 't') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), True) self.assertEqual(_check_win(game['answer_word'], game['masked_word']), True) expected = { 'answer_word': 'cat', 'masked_word': 'cat', 'previous_guesses': 'cabt', 'remaining_misses': 4 } self.assertEqual(game, expected)
def test_start_game_default_value(self): word_list = ['happy', 'party'] expected = { 'answer_word': 'santiago', 'masked_word': '********', 'previous_guesses': '', 'remaining_misses': 5 } game = start_new_game(word_list, 'santiago') self.assertEqual(game, expected)
def test_lose(self): word_list = [] game = start_new_game(word_list, 'house') guess_letter(game, 'a') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'b') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'c') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'd') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'e') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), False) guess_letter(game, 'f') self.assertEqual( _check_game_over(game['answer_word'], game['masked_word'], game['remaining_misses']), True) self.assertEqual(_check_lose(game['remaining_misses']), True) expected = { 'answer_word': 'house', 'masked_word': '****e', 'previous_guesses': 'abcdef', 'remaining_misses': 0 } self.assertEqual(game, expected)
def test_guess_letter_correct(self): word_list = [] expected = { 'answer_word': 'santiago', 'masked_word': '*a***a**', 'previous_guesses': 'a', 'remaining_misses': 5 } game = start_new_game(word_list, 'santiago') guess_letter(game, 'a') self.assertEqual(game, expected)