def test_convert_list_xDim_to_1Dim(self): """ This test is testing function convert_list_xDim_to_1Dim whose purpose is to convert a multi-dimensional list a list to a single dimension """ test_in = ["a", "b", "c", "d", "e"] test_out = ["a", "b", "c", "d", "e"] test_res = utility.convert_list_xDim_to_1Dim(test_in) self.assertEqual(test_res, test_out) test_in = [["a"], ["b"], ["c", "d"], ["e"]] test_out = ["a", "b", "c", "d", "e"] test_res = utility.convert_list_xDim_to_1Dim(test_in) self.assertEqual(test_res, test_out) test_in = [[[[[[[[["a"]]]]]]]], ["b"], [["c"], ["d"]], [[[["e"]]]]] test_out = ["a", "b", "c", "d", "e"] test_res = utility.convert_list_xDim_to_1Dim(test_in) self.assertEqual(test_res, test_out) test_in = [[], ["b"], [["c"]], [[[["e"]]]]] test_out = ["b", "c", "e"] test_res = utility.convert_list_xDim_to_1Dim(test_in) self.assertEqual(test_res, test_out)
def test_get_symbols_list(self): """ This test is testing function get_symbol_list whose purpose is to convert a tree representing a condition in a list giving the names of symbols (options) present in this condition """ sym_a = items[25] sym_b = items[26] sym_c = items[27] sym_d = items[28] sym_e = items[29] sym_f = items[30] # test 1 test_in = utility.Tree([0, sym_a, sym_b]) test_out = [sym_a.get_name(), sym_b.get_name()] test_res = test_in.get_symbols_list() test_out = list(set(test_out)) test_res = list(set(test_res)) test_out.sort() test_res.sort() self.assertEqual(test_res, test_out) # test 2 test_in = utility.Tree([0, [1, sym_a, sym_b], sym_c, sym_d]) test_out = [sym_a.get_name(), sym_b.get_name(), sym_c.get_name(), sym_d.get_name()] test_res = test_in.get_symbols_list() test_out = list(set(utility.convert_list_xDim_to_1Dim(test_out))) test_res = list(set(utility.convert_list_xDim_to_1Dim(test_res))) test_out.sort() test_res.sort() self.assertEqual(test_res, test_out) # test 3 test_in = utility.Tree([0, [1, sym_a, sym_b], [0, sym_c, sym_e]]) test_out = [sym_a.get_name(), sym_b.get_name(), sym_c.get_name(), sym_e.get_name()] test_res = test_in.get_symbols_list() test_out = list(set(utility.convert_list_xDim_to_1Dim(test_out))) test_res = list(set(utility.convert_list_xDim_to_1Dim(test_res))) test_out.sort() test_res.sort() self.assertEqual(test_res, test_out) # test 4 test_in = utility.Tree([0, [1, [0, [1, [0, sym_a, sym_b], sym_c], sym_d], sym_e], sym_f]) test_out = [sym_a.get_name(), sym_b.get_name(), sym_c.get_name(), sym_e.get_name(), sym_d.get_name(), sym_f.get_name()] test_res = test_in.get_symbols_list() test_out = list(set(utility.convert_list_xDim_to_1Dim(test_out))) test_res = list(set(utility.convert_list_xDim_to_1Dim(test_res))) test_out.sort() test_res.sort() self.assertEqual(test_res, test_out)