def test_gets_limited_suggestions(self): custom_word_set = WordSet(set(['bat', 'banana', 'shoe', 'dog'])) scrabble_calc = WordScrabbleCalculator('sdhooeg', custom_word_set) suggestions = scrabble_calc.get_suggestions(1) self.assertEqual(suggestions, ['shoe'])
def test_gets_right_score_with_blank(self): scrabble_calc = WordScrabbleCalculator('ze ra', WordSet(set())) score = scrabble_calc._get_score('zebra', scrabble_calc.word) self.assertEqual(score, 10+1+0+1+1)
def test_gets_suggestions_ordered_by_score_with_blank(self): custom_word_set = WordSet(set(['bat', 'banana', 'shoe', 'dog'])) scrabble_calc = WordScrabbleCalculator('sd ooeg', custom_word_set) suggestions = scrabble_calc.get_suggestions(2) self.assertEqual(suggestions, ['dog', 'shoe'])
def test_gets_right_score(self): scrabble_calc = WordScrabbleCalculator('', WordSet(set())) score = scrabble_calc._get_score('zebra') self.assertEqual(score, 10+1+3+1+1)
def test_gets_no_possible_words(self): custom_word_set = WordSet(set(['bat', 'banana', 'shoe', 'dog'])) scrabble_calc = WordScrabbleCalculator('noluck', custom_word_set) possible_words = scrabble_calc.get_possible_words() self.assertEqual(possible_words, [])
def test_gets_possible_words_with_blank_tile(self): custom_word_set = WordSet(set(['bat', 'banana', 'shoe', 'dog'])) scrabble_calc = WordScrabbleCalculator('sd ooeg', custom_word_set) possible_words = scrabble_calc.get_possible_words() self.assertEqual(set(possible_words), set(['dog', 'shoe']))
def test_when_instantiated_wth_custom_word_set(self): custom_word_set = WordSet(set(['bat', 'banana', 'shoe', 'dog'])) scrabble_calc = WordScrabbleCalculator('groade', custom_word_set) self.assertEqual(scrabble_calc.word_set(), custom_word_set())
def test_when_instantiated_wth_default_word_set(self): default_word_set = WordSet() scrabble_calc = WordScrabbleCalculator('') self.assertEqual(scrabble_calc.word_set(), default_word_set())