コード例 #1
0
    def test_nothing_to_do(self, file_test_xml_all_pass, file_test_list,
                           tempest_config_file):
        """Tests that when there is nothing to do it will return a string
        that is functionally identical to the xml passed in"""

        result = TempestZigZag.process_xml(file_test_xml_all_pass,
                                           file_test_list, tempest_config_file)
        expected = etree.parse(file_test_xml_all_pass).getroot()
        observed = etree.XML(result)

        assert observed.tag == expected.tag
        assert observed.attrib['failures'] == expected.attrib['failures']
        assert observed.attrib['errors'] == expected.attrib['errors']
        assert observed.attrib['tests'] == expected.attrib['tests']
        assert observed.attrib['name'] == 'xml suite created by tempest-zigzag'
        assert len(observed) == len(
            expected
        ) + 1  # the actual number of child elements (testcase) + properties element

        for observed_case in observed:
            # test that the observed cases have the same names as the expected cases
            try:
                # there should be exactly one testcase with a matching name
                assert len([
                    case for case in expected
                    if case.attrib['name'] == observed_case.attrib['name']
                ]) == 1
            except KeyError:  # <properties> do not have a name attribute
                pass
コード例 #2
0
    def test_setupclass_failure(self, file_test_xml_setup_failure,
                                file_test_list_with_whitespace,
                                tempest_config_file):
        """Tests that the correct testcase elements will be created
        when a setUpClass failure is found"""

        result = TempestZigZag.process_xml(file_test_xml_setup_failure,
                                           file_test_list_with_whitespace,
                                           tempest_config_file)
        observed = etree.XML(result)
        new_case_count = 0

        assert len(observed) == 11  # 10 test cases and 1 properties element
        assert '5' == observed.attrib['errors']
        assert '0' == observed.attrib['failures']
        for testcase in observed.findall('testcase'):
            if testcase.attrib[
                    'classname'] == 'tempest.api.compute.admin.test_aggregates.AggregatesAdminTestJSON':
                error_tag = testcase.find('error')
                assert error_tag is not None
                assert 'An unexpected error prevented the server from fulfilling your request.' in error_tag.text
                assert not testcase.find(
                    'failure')  # there should not be any failures
                new_case_count += 1
        assert new_case_count == 5
コード例 #3
0
    def test_teardownclass_failure_tests_not_found(
            self, file_test_xml_teardown_class_not_in_list, file_test_list,
            tempest_config_file):
        """Tests when a tearDownClass failure exists in the provided xml
        but there are no corresponding tests in the test list
        """

        result = TempestZigZag.process_xml(
            file_test_xml_teardown_class_not_in_list, file_test_list,
            tempest_config_file)
        expected = etree.parse(
            file_test_xml_teardown_class_not_in_list).getroot()
        observed = etree.XML(result)

        assert observed.tag == expected.tag
        assert observed.attrib['failures'] == expected.attrib['failures']
        assert observed.attrib['errors'] == expected.attrib['errors']
        assert observed.attrib['tests'] == expected.attrib['tests']
        assert observed.attrib['name'] == 'xml suite created by tempest-zigzag'
        assert len(observed) == len(
            expected
        ) + 1  # the actual number of child elements (testcase) + properties element
        # the broken testcase should be the last case in the list
        assert 'tearDownClass (tempest.oops.this.class.is.not.in.the.TestList)' == observed[
            -1].attrib['name']
コード例 #4
0
ファイル: cli.py プロジェクト: rcbops/tempest-zigzag
def main(junit_input_file, test_list, config_file):
    """Process multiple files created by tempest into a single accurate junit xml artifact"""
    try:
        click.echo(str(TempestZigZag.process_xml(junit_input_file, test_list, config_file)))
    except(TempestXMLAccessError, Exception) as e:
        click.echo(click.style(str(e), fg='red'))
        click.echo(click.style("\nFailed!", fg='red'))

        sys.exit(1)
コード例 #5
0
ファイル: test_xsd.py プロジェクト: rcbops/tempest-zigzag
def test_valid_xsd_generation(file_test_xml_setup_failure,
                              file_test_list_with_whitespace,
                              tempest_config_file, mocker):
    """Verify that 'get_xsd' returns an XSD stream that can be used to validate JUnitXML."""

    # Mock
    zz = mocker.MagicMock()
    xmlpf = XmlParsingFacade(zz)

    result = TempestZigZag.process_xml(file_test_xml_setup_failure,
                                       file_test_list_with_whitespace,
                                       tempest_config_file)
    xml_doc = etree.fromstring(result)

    # noinspection PyProtectedMember
    xmlschema = etree.XMLSchema(etree.parse(xmlpf._get_xsd()))

    # Test
    xmlschema.assertValid(xml_doc)
コード例 #6
0
    def test_teardownclass_multiple_failures(
            self, file_test_xml_teardown_multiple_failures,
            file_test_list_with_whitespace, tempest_config_file):
        """Tests that the correct testcase elements will be altered
        when multiple teardown failures are found"""

        result = TempestZigZag.process_xml(
            file_test_xml_teardown_multiple_failures,
            file_test_list_with_whitespace, tempest_config_file)
        observed = etree.XML(result)

        assert len(observed) == 11  # 10 test cases and 1 properties element
        assert '10' == observed.attrib['errors']
        assert '0' == observed.attrib['failures']
        # all test cases should be set to error in this case
        for testcase in observed.findall('testcase'):
            error_tag = testcase.find('error')
            assert error_tag is not None
            assert 'An unexpected error prevented the server from fulfilling your request.' in error_tag.text
            assert not testcase.find(
                'failure')  # there should not be any failures
コード例 #7
0
def main(junit_input_file, test_list):
    """Process multiple files created by tempest into a single accurate junit xml artifact"""
    TempestZigZag(junit_input_file, test_list)