Ejemplo n.º 1
0
 def test_fill_testcase_response(self, fname):
     xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname))
     name, value = utils.fill_response_property(xml_root)
     filled = utils.etree_to_string(xml_root)
     assert name == 'dump2polarion'
     assert value
     assert '<response-property name="dump2polarion" value=' in filled
Ejemplo n.º 2
0
 def test_fill_testsuites_response(self):
     fname = 'complete_transform_noresponse.xml'
     xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname))
     name, value = utils.fill_response_property(xml_root)
     filled = utils.etree_to_string(xml_root)
     assert name == 'dump2polarion'
     assert value
     assert '<property name="polarion-response-dump2polarion" value=' in filled
Ejemplo n.º 3
0
 def test_fill_custom_testcase_response(self):
     fname = 'testcases_noresponse.xml'
     xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname))
     name, value = utils.fill_response_property(xml_root, 'test', 'test')
     filled = utils.etree_to_string(xml_root)
     assert name == 'test'
     assert value == 'test'
     assert '<response-property name="test" value="test"' in filled
     # make sure response properties are on top
     assert '<testcases project-id="RHCF3">\n  <response-properties>' in filled
Ejemplo n.º 4
0
def submit_and_verify(xml_str=None,
                      xml_file=None,
                      xml_root=None,
                      config=None,
                      **kwargs):
    """Submits results to the Polarion Importer and checks that it was imported."""
    try:
        config = config or configuration.get_config()
        xml_root = _get_xml_root(xml_root, xml_str, xml_file)
        response_property = utils.fill_response_property(xml_root)
    except Dump2PolarionException as err:
        logger.error(err)
        return False

    verification_skipped = False

    if kwargs.get('no_verify'):
        verification_func = None
    else:
        msgbus_login = kwargs.get('msgbus_user') or config.get(
            'msgbus_username') or kwargs.get('user') or config.get(
                'username') or os.environ.get('POLARION_USERNAME')
        msgbus_pwd = kwargs.get('msgbus_password') or config.get(
            'msgbus_password') or kwargs.get('password') or config.get(
                'password') or os.environ.get('POLARION_PASSWORD')

        verification_func = msgbus.get_verification_func(
            config.get('message_bus'),
            response_property,
            user=msgbus_login,
            password=msgbus_pwd,
            log_file=kwargs.get('msgbus_log'))
        if not verification_func:
            verification_skipped = True

    response = submit(xml_root=xml_root, config=config, **kwargs)

    if verification_func:
        response = verification_func(skip=not response,
                                     timeout=kwargs.get('verify_timeout'))
    elif verification_skipped:
        # we wanted to verify the import but it didn't happen for some reason
        response = False

    return bool(response)
Ejemplo n.º 5
0
 def test_nofill_response(self, fname):
     xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname))
     name, value = utils.fill_response_property(xml_root)
     assert name == 'test'
     assert value == 'test'
Ejemplo n.º 6
0
 def test_fill_invalid_testsuites_response(self):
     xml_root = utils.get_xml_root_from_str('<invalid/>')
     with pytest.raises(Dump2PolarionException) as excinfo:
         utils.fill_response_property(xml_root, 'test', 'test')
     assert 'XML file is not in expected format' in str(excinfo.value)