def test_create_xml_tree(self): tree = create_xml_tree(BytesIO(b'<foo><baz/><bar>glurp</bar></foo>')) self.assertIsInstance( tree, etree._Element # pylint: disable=protected-access ) self.assertEqual(tree.tag, 'foo')
def main(gmp, args): # pylint: disable=undefined-variable check_args(args) xml_doc = args.script[1] print('\nSending task(s)...') xml_tree = create_xml_tree(xml_doc) parse_send_xml_tree(gmp, xml_tree) print('\n Task(s) sent!\n')
def main(gmp, args): # pylint: disable=undefined-variable check_args(args) xml_doc = args.script[1] print('\nSending schedules...') xml_tree = create_xml_tree(xml_doc) parse_send_xml_tree(gmp, xml_tree) print('\n Schedule(s) created!\n')
def main(gmp: Gmp, args: Namespace) -> None: # pylint: disable=undefined-variable check_args(args) xml_doc = args.script[1] print('\nSending targets...') xml_tree = create_xml_tree(xml_doc) parse_send_xml_tree(gmp, xml_tree) print('\n Target(s) created!\n')
def main(gmp: Gmp, args: Namespace) -> None: # pylint: disable=undefined-variable, unused-argument parser = ArgumentParser( prefix_chars="+", add_help=False, formatter_class=RawTextHelpFormatter, description=HELP_TEXT, ) parser.add_argument( "+h", "++help", action="help", help="Show this help message and exit.", ) parser.add_argument( "+x", "++xml-file", dest='xml', type=str, required=True, help='xml file containing tasks', ) script_args, _ = parser.parse_known_args() # check_args(args) print('\nSending task(s)...') xml_tree = create_xml_tree(script_args.xml) tasks = parse_send_xml_tree(gmp, xml_tree) for task in tasks: print(task) print('\nTask(s) sent!\n')
def test_create_xml_tree_invalid_xml(self): with self.assertRaises(SystemExit): with self.assertRaises(etree.Error): create_xml_tree(BytesIO(b'<foo><baz/><bar>glurp<bar></foo>'))
def test_create_xml_tree_invalid_file(self): target_xml_path = CWD / 'invalid_file.xml' with self.assertRaises(SystemExit): with self.assertRaises(OSError): create_xml_tree(str(target_xml_path))