def test_union_with_expand(self): expected = 'node[1-6]' list1 = 'node[1-2]' list2 = 'node[3-4]' list3 = 'node6' list4 = 'node5' test = hl.union_nodes(list1, list2, list3, list4) self.assertEqual(test, expected)
def test_union_multiple(self): expected = 'node[1-6]' list1 = ['node1', 'node2'] list2 = ['node3', 'node4'] list3 = ['node6'] list4 = ['node5'] test = hl.union_nodes(list1, list2, list3, list4) self.assertEqual(test, expected)
def test_union_as_string(self): expected = 'node[1-6]' list1 = ['node1', 'node2'] list2 = 'node3,node4' list3 = ['node6'] list4 = 'node5' test = hl.union_nodes(list1, list2, list3, list4) self.assertEqual(test, expected)
def test_union_simple(self): expected = 'node[1-12]' list1 = \ ['node1', 'node2', 'node3', 'node4', 'node5', 'node7', 'node8', 'node10', 'node11', 'node12'] list2 = ['node5', 'node6', 'node7', 'node8', 'node9', 'node1'] test = hl.union_nodes(list1, list2) self.assertEqual(test, expected)
def main(): parser = argparse.ArgumentParser(usage=msg()) parser.add_argument("-d", "--delimiters", dest="delimiter", nargs="*") parser.add_argument("-s", "--size", dest="size_hostlist", nargs="*") parser.add_argument("-e", "--expand", dest="expand") parser.add_argument("-a", "--abbreviate", dest="compress_range") parser.add_argument("-t", "--tighten", dest="compress") parser.add_argument("-m", "--minus", dest="diff", nargs="*") parser.add_argument("-i", "--intersection", dest="intersection", nargs="*") parser.add_argument("-u", "--union", dest="union", nargs="*") parser.add_argument("-n", "--nth", dest="nth", nargs="*") parser.add_argument("-R", "--remove", dest="remove_node", nargs="*") parser.add_argument("-S", "--sort", dest="sort") parser.add_argument("-c", "--count", dest="count") parser.add_argument("-F", "--find", dest="find", nargs="*") parser.add_argument("-X", "--xor", dest="xor", nargs="*") parser.add_argument("-x", "--exclude", dest="exclude", nargs="*") parser.add_argument("-q", "--quiet", dest="quiet") parser.add_argument("-f", "--filter", dest="filter") args = parser.parse_args() if args.delimiter: print(hl.delimiter(args.delimiter[1], args.delimiter[0])) if args.size_hostlist: print(hl.size_hostlist(args.size_hostlist[1], int(args.size_hostlist[0]))) if args.expand: print(hl.expand(args.expand)) if args.compress_range: print(hl.compress_range(args.compress_range)) if args.compress: print(hl.compress(args.compress)) if args.diff: print(hl.diff(*args.diff)) if args.intersection: print(hl.intersect(*args.intersection)) if args.union: print(hl.union_nodes(*args.union)) if args.nth: print(hl.nth(args.nth[1], args.nth[0])) if args.remove_node: print(hl.remove_node(args.remove_node[1], args.remove_node[0])) if args.sort: print(hl.sort_nodes(args.sort)) if args.count: print(hl.count(args.count)) if args.find: print(hl.find(args.find[1], args.find[0])) if args.xor: print(hl.xor(*args.xor)) if args.exclude: print(hl.exclude(*args.exclude)) if args.quiet: hl.quiet(args.quiet) if args.filter: print(hl.filter_python(args.filter))