Exemplo n.º 1
0
 def test_elementtree_parse_file_error(self, mock_parse):
     err = ET.ParseError()
     err.msg = "it broke"
     err.lineno = 1
     mock_parse.side_effect = err
     try:
         utils.elementtree_parse_file("test_file")
     except ET.ParseError as err:
         self.assertEqual(str(err), "it broke (test_file, line 1)")
     else:
         self.fail("Expected ParseError")
Exemplo n.º 2
0
 def test_elementtree_parse_file_error(self, mock_parse):
     err = ET.ParseError()
     err.msg = "it broke"
     err.lineno = 1
     mock_parse.side_effect = err
     try:
         utils.elementtree_parse_file("test_file")
     except ET.ParseError as err:
         assert str(err) == "it broke (test_file, line 1)"
     else:
         assert False  # Expected ParseError
Exemplo n.º 3
0
 def test_elementtree_parse_file_error(self, mock_parse):
     err = ET.ParseError()
     err.msg = "it broke"
     err.lineno = 1
     mock_parse.side_effect = err
     try:
         utils.elementtree_parse_file("test_file")
     except ET.ParseError as err:
         self.assertEqual(str(err), "it broke (test_file, line 1)")
     else:
         self.fail("Expected ParseError")
Exemplo n.º 4
0
 def load_junit(self, filename):
     results = []
     tree = elementtree_parse_file(filename)
     testsuite = tree.getroot()
     for testcase in testsuite.iter("testcase"):
         result = {
             "ClassName": testcase.attrib["classname"],
             "Method": testcase.attrib["name"],
             "Outcome": "Pass",
             "StackTrace": "",
             "Message": "",
             "Stats": {
                 "duration": testcase.get("time")
             },
             "SourceFile": filename,
         }
         for element in testcase.iter():
             if element.tag not in ["failure", "error"]:
                 continue
             result["Outcome"] = "Fail"
             if element.text:
                 result["StackTrace"] += element.text + "\n"
             message = element.get("type", "")
             if element.get("message"):
                 message += ": " + element.get("message", "")
                 result["Message"] += message + "\n"
         results.append(result)
     return results
Exemplo n.º 5
0
 def load_junit(self, filename):
     results = []
     tree = elementtree_parse_file(filename)
     testsuite = tree.getroot()
     for testcase in testsuite.iter('testcase'):
         result = {
             'ClassName': testcase.attrib['classname'],
             'Method': testcase.attrib['name'],
             'Outcome': 'Pass',
             'StackTrace': '',
             'Message': '',
             'Stats': {
                 'duration': testcase.get('time'),
             },
             'SourceFile': filename,
         }
         for element in testcase.iter():
             if element.tag not in ['failure', 'error']:
                 continue
             result['Outcome'] = 'Fail'
             if element.text:
                 result['StackTrace'] += element.text + '\n'
             message = element.get('type', '')
             if element.get('message'):
                 message += ': ' + element.get('message', '')
                 result['Message'] += message + '\n'
         results.append(result)
     return results
Exemplo n.º 6
0
    def _parse_item(self, item):
        root = elementtree_parse_file(self.directory + '/' + item)
        members = []

        parent = self.strip_extension(item)

        for item in self.get_item_elements(root):
            members.append(self.get_item_name(item, parent))

        return members
Exemplo n.º 7
0
    def _parse_item(self, item):
        root = elementtree_parse_file(self.directory + "/" + item)
        members = []

        parent = self.strip_extension(item)

        for item in self.get_item_elements(root):
            members.append(self.get_item_name(item, parent))

        return members
Exemplo n.º 8
0
    def _process_metadata(self):
        self.logger.info(f"Processing retrieved metadata in {self.retrieve_dir}")
        path = self.retrieve_dir / "profiles" / f"{self.profile_name}.profile"
        self.tree = elementtree_parse_file(path)

        self._set_apps_visible()
        self._set_classes_enabled()
        self._set_fields_editable()
        self._set_fields_readable()
        self._set_pages_enabled()
        self._set_tabs_visibility()
        self._set_record_types()

        self.tree.write(
            path, "utf-8", xml_declaration=True, default_namespace=self.namespaces["sf"]
        )
Exemplo n.º 9
0
    def _process_metadata(self):
        self.logger.info("Processing retrieved metadata in {}".format(
            self.tempdir))
        path = os.path.join(self.tempdir, "profiles", "Admin.profile")
        self.tree = elementtree_parse_file(path)

        self._set_apps_visible()
        self._set_classes_enabled()
        self._set_fields_editable()
        self._set_fields_readable()
        self._set_pages_enabled()
        self._set_tabs_visibility()
        self._set_record_types()

        self.tree.write(path,
                        "utf-8",
                        xml_declaration=True,
                        default_namespace=self.namespaces["sf"])
Exemplo n.º 10
0
def parse_robot_output(path):
    """ Parses a robotframework output.xml file into individual test xml files """

    tree = elementtree_parse_file(path)
    root = tree.getroot()
    return get_robot_tests(root, root)
Exemplo n.º 11
0
 def test_elementtree_parse_file(self, mock_parse):
     _marker = object()
     mock_parse.return_value = _marker
     self.assertIs(utils.elementtree_parse_file("test_file"), _marker)
Exemplo n.º 12
0
 def test_elementtree_parse_file(self, mock_parse):
     _marker = object()
     mock_parse.return_value = _marker
     assert utils.elementtree_parse_file("test_file") == _marker
Exemplo n.º 13
0
 def test_elementtree_parse_file(self, mock_parse):
     _marker = object()
     mock_parse.return_value = _marker
     self.assertIs(utils.elementtree_parse_file('test_file'), _marker)