def test_valid_removal(): '''Unit test for adding letters to the bag''' rules = game_pieces.gameRules() # test 1 removal_one = {'a': 1, 'b': 1} bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.valid_removal(removal_one) == True: print("Test 1: SUCCESS") else: print("Test 1: FAILURE") # test 2 removal_two = {} bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.valid_removal(removal_two) == True: print("Test 2: SUCCESS") else: print("Test 2: FAILURE") # test 3 removal_three = {'a': 2} bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.valid_removal(removal_three) == False: print("Test 3: SUCCESS") else: print("Test 3: FAILURE") # test 4 removal_four = {'ab': 1} bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.valid_removal(removal_four) == False: print("Test 4: SUCCESS") else: print("Test 4: FAILURE") # test 5 removal_five = 'string' bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) try: bag.valid_removal(removal_five) print("Test 5: FAILURE") except AssertionError: print("Test 5: SUCCESS")
def test_get_letter_dict(): '''Unit test for retrieving letter_dict''' rules = game_pieces.gameRules() bag = game_pieces.bag(rules) if bag.get_letter_dict() == {}: print("SUCCESS") else: print("FAILURE")
def test_remove_letters(): '''Unit test for remove letters''' rules = game_pieces.gameRules() TEST_LETTER_DIST_REMOVAL = { 'a': 0, 'c': 1, 'b': 0, 'e': 1, 'd': 1, 'g': 1, 'f': 1, 'i': 1, 'h': 1, 'k': 1, 'j': 1, 'm': 1, 'l': 1, 'o': 1, 'n': 1, 'q': 1, 'p': 1, 's': 1, 'r': 1, 'u': 1, 't': 1, 'w': 1, 'v': 1, 'y': 1, 'x': 1, 'z': 1 } # test 1 removal_one = {'a': 1, 'b': 1} bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) bag.remove_letters(removal_one) if bag.number_of_letters() == 24: print("Test 1: SUCCESS") else: print("Test 1: FAILURE") # Test 2 if bag.get_letter_dict() == TEST_LETTER_DIST_REMOVAL: print("Test 2: SUCCESS") else: print("Test 2: FAILURE") #test 3 removal_two = {'a': 2} try: bag.remove_letters(removal_two) print("Test 3: FAILURE") except game_pieces.bagRemovalError as error: print("Test 3: SUCCESS", error)
def test_add_letters(): '''Unit test for adding letters to the bag''' rules = game_pieces.gameRules() bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if (bag.get_letter_dict() == TEST_LETTER_DIST): print("SUCCESS") else: print("FAILURE")
def test_number_of_letters(): '''Unit test for returning correct number of letters''' rules = game_pieces.gameRules() # test 1 bag = game_pieces.bag(rules) if bag.number_of_letters() == 0: print("Test 1: SUCCESS") else: print("Test 1: FAILURE") # test 2 bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.number_of_letters() == 26: print("Test 2: SUCCESS") else: print("Test 2: FAILURE")
def test_is_empty(): '''Unit test for is_empty()''' # Test 1 rules = game_pieces.gameRules() bag = game_pieces.bag(rules) if bag.is_empty() == True: print("Test 1: SUCCESS") else: print("Test 1: FAILURE") # Test 2 rules = game_pieces.gameRules() bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.is_empty() == True: print("Test 1: FAILURE") else: print("Test 1: SUCCESS")
def test_give_letters(): '''Unit test for give letters''' # Test 1 - take all letters rules = game_pieces.gameRules() bag = game_pieces.bag(rules) bag.add_letters(TEST_LETTER_DIST) if bag.give_letters(26) == TEST_LETTER_DIST: print("Test 1.0: SUCCESS") else: print("Test 1.0: FAILURE") if bag.is_empty(): print("Test 1.1: SUCCESS") else: print("Test 1.1: FAILURE") # Test 2 - take more letters rules = game_pieces.gameRules() bag = game_pieces.bag(rules) bag.add_letters({'a': 1}) if bag.give_letters(2) == {'a': 1}: print("Test 2: SUCCESS") else: print("Test 2: FAILURE") # Test 3 - bag is empty rules = game_pieces.gameRules() bag = game_pieces.bag(rules) if bag.give_letters(2) == {}: print("Test 3: SUCCESS") else: print("Test 3: FAILURE") # Test 4 -- Future Simulation print("PLACEHOLDER FOR FUTURE SIMULATION")
def test_bag(): '''Unit test for initializing bag''' rules = game_pieces.gameRules() bag = game_pieces.bag(rules)