def test_matrix_initialization_empty_elements(self): """ Empty matrix """ # arrange add_weight = 1 remove_weight = 2 edit_matrix = [[], [], []] # act actual_matrix = main.initialize_edit_matrix(tuple(edit_matrix), add_weight, remove_weight) # assert self.assertListEqual(edit_matrix, actual_matrix)
def test_matrix_initialization_none_params(self): """ None parameters """ # arrange add_weight = None remove_weight = None edit_matrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]] # act actual_matrix = main.initialize_edit_matrix(tuple(edit_matrix), add_weight, remove_weight) # assert self.assertListEqual(edit_matrix, actual_matrix)
def test_matrix_initialization_wrong_params(self): """ Wrong type parameters """ # arrange add_weight = 'a' remove_weight = [] edit_matrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]] # act actual_matrix = main.initialize_edit_matrix(tuple(edit_matrix), add_weight, remove_weight) # assert self.assertListEqual(edit_matrix, actual_matrix)
def test_find_pathl_again(self): """ Ideal scenario # 2 """ original_word = 'cat' target_word = 'doge' add_weight = 1 remove_weight = 2 substitute_weight = 3 edit_matrix = tuple(main.generate_edit_matrix(len(original_word) + 1, len(target_word) + 1)) edit_matrix = tuple(main.initialize_edit_matrix(edit_matrix, add_weight, remove_weight)) edit_matrix = main.fill_edit_matrix(edit_matrix, add_weight, remove_weight, substitute_weight, original_word, target_word) print("best path cost " + str(edit_matrix[len(original_word)][len(target_word)])) main.print_path(edit_matrix, original_word, target_word, add_weight, remove_weight, substitute_weight)
def test_matrix_initialization_ideal(self): """ Ideal scenario """ # arrange add_weight = 1 remove_weight = 2 edit_matrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]] expected_matrix = [[0, 1, 2, 3, 4, 5], [2, 0, 0, 0, 0, 0], [4, 0, 0, 0, 0, 0], [6, 0, 0, 0, 0, 0], [8, 0, 0, 0, 0, 0]] # act actual_matrix = main.initialize_edit_matrix(tuple(edit_matrix), add_weight, remove_weight) # assert self.assertListEqual(expected_matrix, actual_matrix)