Esempio n. 1
0
def test_build_url_not_defined(suite):
    manager.install(Plugin(), is_internal=False)
    manager.activate('ci links')
    test = suite.add_test()
    test.when_run.fail()
    summary = suite.run()
    result = summary.get_all_results_for_test(test)[0]
    log_link = result.details.all().get('log_link')
    assert log_link is None
Esempio n. 2
0
def test_adds_link_for_passing_test(suite, build_url):
    manager.install(Plugin(), is_internal=False)
    manager.activate('ci links')
    summary = suite.run()
    for test in suite:
        result = summary.get_all_results_for_test(test)[0]
        log_link = result.details.all().get('log_link')
        expected_log_link = '/'.join((build_url.rstrip('/'), 'artifact',
                                      *result.get_log_path().split(os.sep)))
        assert log_link == expected_log_link
Esempio n. 3
0
def test_build_url_defined(suite, build_url):
    manager.install(Plugin(), is_internal=False)
    manager.activate('ci links')
    test = suite.add_test()
    test.when_run.fail()
    summary = suite.run()
    result = summary.get_all_results_for_test(test)[0]
    log_link = result.details.all().get('log_link')
    expected_log_link = '/'.join((build_url.rstrip('/'), 'artifact',
                                  *result.get_log_path().split(os.sep)))
    assert log_link == expected_log_link
Esempio n. 4
0
def test_overridden_build_url_getter(suite):
    plugin = PluginWithOverriddenBuildURLGetter()
    manager.install(plugin, is_internal=False)
    manager.activate('ci links')
    test = suite.add_test()
    test.when_run.fail()
    summary = suite.run()
    result = summary.get_all_results_for_test(test)[0]
    log_link = result.details.all().get('log_link')
    local_log_path = '/'.join(result.get_log_path().split(os.sep))
    expected_log_link = '%s/artifact/%s' % (plugin.build_url, local_log_path)
    assert log_link == expected_log_link
Esempio n. 5
0
def test_nondefault_link_template(
        suite, config_override, build_url, template):
    manager.install(Plugin(), is_internal=False)
    config_override('plugin_config.ci_links.link_template', template)
    manager.activate('ci links')
    test = suite.add_test()
    test.when_run.fail()
    summary = suite.run()
    result = summary.get_all_results_for_test(test)[0]
    log_link = result.details.all().get('log_link')
    local_log_path = '/'.join(result.get_log_path().split(os.sep))
    expected_log_link = template % {'build_url': build_url.rstrip('/'),
                                    'log_path': local_log_path}
    assert log_link == expected_log_link
Esempio n. 6
0
def test_nondefault_build_url_environment_variable(suite, config_override,
                                                   build_url_env_var):
    env_var_name, env_var_value = build_url_env_var
    manager.install(Plugin(), is_internal=False)
    config_override('plugin_config.ci_links.build_url_environment_variable',
                    env_var_name)
    manager.activate('ci links')
    test = suite.add_test()
    test.when_run.fail()
    summary = suite.run()
    result = summary.get_all_results_for_test(test)[0]
    log_link = result.details.all().get('log_link')
    expected_log_link = '/'.join((env_var_value.rstrip('/'), 'artifact',
                                  *result.get_log_path().split(os.sep)))
    assert log_link == expected_log_link