How to use the betelgeuse.collector function in Betelgeuse

To help you get started, we’ve selected a few Betelgeuse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SatelliteQE / betelgeuse / tests / test_collector.py View on Github external
def test_collect_tests(path):
    """Check if ``collect_tests`` 'tests/data'collect tests."""
    tests = collector.collect_tests(path)
    assert 'tests/data/test_sample.py' in tests
    assert len(tests['tests/data/test_sample.py']) == 4

    # Check if we are not doing a specific python module collection
    if path.endswith('.py'):
        return

    assert 'tests/data/ignore_dir/test_ignore_dir.py' in tests
    assert len(tests['tests/data/ignore_dir/test_ignore_dir.py']) == 2
github SatelliteQE / betelgeuse / betelgeuse / __init__.py View on Github external
'polarion-testrun-id',
        'polarion-testrun-template-id',
        'polarion-testrun-title',
        'polarion-testrun-type-id',
        'polarion-user-id',
    )
    for name, value in custom_fields.items():
        if (not name.startswith('polarion-custom-') and
                not name.startswith('polarion-response-') and
                name not in properties_names):
            name = 'polarion-custom-{}'.format(name)
        properties.append(create_xml_property(name, value))
    testsuites.append(properties)

    testcases = {}
    for test in itertools.chain(*collector.collect_tests(
            source_code_path, collect_ignore_path).values()):
        update_testcase_fields(config, test)
        testcases[test.junit_id] = test
    testsuite = ElementTree.parse(junit_path).getroot()
    if testsuite.tag == 'testsuites':
        testsuite = testsuite.getchildren()[0]

    for testcase in testsuite.iterfind('testcase'):
        junit_test_case_id = '{0}.{1}'.format(
            testcase.get('classname'), testcase.get('name'))
        pytest_parameters = None
        if '[' in junit_test_case_id:
            junit_test_case_id, pytest_parameters = junit_test_case_id.split(
                '[', 1)
            pytest_parameters = pytest_parameters[:-1]
        source_test_case = testcases.get(junit_test_case_id)
github SatelliteQE / betelgeuse / betelgeuse / __init__.py View on Github external
requirements.set('project-id', project)
    if response_property:
        response_properties = ElementTree.Element('response-properties')
        element = ElementTree.Element('response-property')
        element.set('name', response_property[0])
        element.set('value', response_property[1])
        response_properties.append(element)
        requirements.append(response_properties)
    properties = ElementTree.Element('properties')
    properties.append(create_xml_property(
        'dry-run', 'true' if dry_run else 'false'))
    properties.append(create_xml_property(
        'lookup-method', lookup_method))
    requirements.append(properties)

    source_testcases = itertools.chain(*collector.collect_tests(
        source_code_path, collect_ignore_path).values())
    cache = []
    for testcase in source_testcases:
        update_testcase_fields(config, testcase)
        if ('requirement' in testcase.fields and
                testcase.fields['requirement'] not in cache):
            requirement_title = testcase.fields['requirement']
            cache.append(requirement_title)
            requirements.append(create_xml_requirement(
                config, requirement_title, assignee, approver))

    et = ElementTree.ElementTree(requirements)
    et.write(output_path, encoding='utf-8', xml_declaration=True)