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
def test_slash_list_plugins_for_internal_plugins(report_stream): internal_plugin = InternalPlugin() manager.install(internal_plugin, is_internal=True) slash_list_plugins([], report_stream=report_stream) output = report_stream.getvalue() assert output assert internal_plugin.get_name() in manager.get_installed_plugins() assert internal_plugin.get_name() not in output assert '--internal-plugin-option' not in output
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
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
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
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
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