def test_remove_testsuites_response_property(self): fname = "complete_transform.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) filled = utils.etree_to_string(xml_root) assert '<property name="polarion-response-test"' in filled properties.remove_response_property(xml_root) filled = utils.etree_to_string(xml_root) assert '<property name="polarion-response-test"' not in filled
def test_add_testcases_dry_run(self): fname = "testcases_noprop.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) filled = utils.etree_to_string(xml_root) assert "dry-run" not in filled properties.set_dry_run(xml_root, True) filled = utils.etree_to_string(xml_root) assert 'property name="dry-run" value="true"' in filled
def test_add_testcases_lookup_property(self): fname = "testcases_noprop.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) filled = utils.etree_to_string(xml_root) assert "lookup-method" not in filled properties.set_lookup_method(xml_root, "name") filled = utils.etree_to_string(xml_root) assert 'property name="lookup-method" value="name"' in filled
def test_remove_testcases_response_property(self): fname = "testcases.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) filled = utils.etree_to_string(xml_root) assert '<response-property name="test"' in filled properties.remove_response_property(xml_root) filled = utils.etree_to_string(xml_root) assert "<response-properties" not in filled
def test_remove_testcases_property(self): fname = "testcases.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) filled = utils.etree_to_string(xml_root) assert '<property name="lookup-method"' in filled properties.remove_property(xml_root, "lookup-method") filled = utils.etree_to_string(xml_root) assert '<property name="lookup-method"' not in filled
def test_fill_testcase_response(self, fname): xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) name, value = properties.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
def test_fill_testrun_present(self): fname = "complete_notransform.xml" fname = os.path.join(conf.DATA_PATH, fname) xml_root = utils.get_xml_root(fname) properties.xunit_fill_testrun_id(xml_root, "not_used") filled = utils.etree_to_string(xml_root) assert 'name="polarion-testrun-id" value="5_8_0_17"' in filled
def submit(xml_str=None, xml_file=None, xml_root=None, config=None, **kwargs): """Submits results to the Polarion Importer.""" try: config = config or configuration.get_config() xml_root = _get_xml_root(xml_root, xml_str, xml_file) credentials = _get_credentials(config, **kwargs) submit_target = _get_submit_target(xml_root, config) utils.xunit_fill_testrun_id(xml_root, kwargs.get('testrun_id')) xml_input = utils.etree_to_string(xml_root) except Dump2PolarionException as err: logger.error(err) return logger.info("Submitting results to {}".format(submit_target)) files = {'file': ('results.xml', xml_input)} try: response = requests.post(submit_target, files=files, auth=credentials, verify=False) # pylint: disable=broad-except except Exception as err: logger.error(err) response = None if response is None: logger.error("Failed to submit results to {}".format(submit_target)) elif response: logger.info("Results received by the Importer (HTTP status {})".format( response.status_code)) else: logger.error("HTTP status {}: failed to submit results to {}".format( response.status_code, submit_target)) return response
def submit(xml_str=None, xml_file=None, xml_root=None, config=None, session=None, **kwargs): """Submits data to the Polarion Importer.""" try: config = config or configuration.get_config() xml_root = _get_xml_root(xml_root, xml_str, xml_file) credentials = _get_credentials(config, **kwargs) submit_target = _get_submit_target(xml_root, config) utils.xunit_fill_testrun_id(xml_root, kwargs.get('testrun_id')) xml_input = utils.etree_to_string(xml_root) session = session or utils.get_session(credentials, config) except Dump2PolarionException as err: logger.error(err) return logger.info("Submitting data to {}".format(submit_target)) files = {'file': ('results.xml', xml_input)} try: response = session.post(submit_target, files=files) # pylint: disable=broad-except except Exception as err: logger.error(err) response = None return validate_response(response, submit_target)
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 = properties.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
def test_fill_custom_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, 'test', 'test') filled = utils.etree_to_string(xml_root) assert name == 'test' assert value == 'test' assert '<property name="polarion-response-test" value="test"' in filled
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
def submit(xml_root, submit_config, session, dry_run=None, **kwargs): """Submits data to the Polarion Importer.""" properties.xunit_fill_testrun_id(xml_root, kwargs.get("testrun_id")) if dry_run is not None: properties.set_dry_run(xml_root, dry_run) xml_input = utils.etree_to_string(xml_root) logger.info("Submitting data to %s", submit_config.submit_target) files = {"file": ("results.xml", xml_input)} try: response = session.post(submit_config.submit_target, files=files) # pylint: disable=broad-except except Exception as err: logger.error(err) response = None return SubmitResponse(response)
def test_fill_testrun_missing(self): fname = "properties.xml" xml_root = utils.get_xml_root(os.path.join(conf.DATA_PATH, fname)) properties.xunit_fill_testrun_id(xml_root, "5_8_0_17") filled = utils.etree_to_string(xml_root) assert 'name="polarion-testrun-id" value="5_8_0_17"' in filled