Beispiel #1
0
def get_url_and_name_build_in_chain(build_id, chained_builds, project,
                                    request):
    """ This function find build in chain and return its name and link

    :param build_id: id of selected build
    :type build_id: int
    :param chained_builds: list of build in chain
    :type chained_builds: list
    :param project: builder project
    :param request: request object
    :return: tuple with two elements: link to build and build name
    """
    from buildbot.status.web.base import path_to_build_by_params

    build_url, build_name = None, None

    selected_build = next(
        ifilter(lambda b: b['id'] == build_id, chained_builds), None)

    if selected_build:
        build_url = path_to_build_by_params(
            request,
            selected_build['buildername'],
            selected_build['number'],
            project,
        )
        build_name = "{builder_name} #{build_number}".format(
            builder_name=selected_build['buildername'],
            build_number=selected_build['number'],
        )

    return build_url, build_name
Beispiel #2
0
    def test_path_to_build_without_params(self, mock_path_to_builder_by_params):
        mock_path_to_builder_by_params.return_value = 'test-url'
        stub_request = StubRequest(args={})
        expected_url = 'test-url/builds/16'

        url = path_to_build_by_params(stub_request, 'test-builder', 16, 'test-project')

        self.assertEqual(url, expected_url)
Beispiel #3
0
    def test_path_to_build_without_codebases(self, mock_path_to_builder_by_params):
        mock_path_to_builder_by_params.return_value = 'test-url'
        stub_request = StubRequest(args={'fmod_branch': ['master']})
        expected_url = 'test-url/builds/16'

        url = path_to_build_by_params(stub_request, 'test-builder', 16, 'test-project', False)

        self.assertEqual(url, expected_url)
Beispiel #4
0
    def test_path_to_build_with_multiple_params(self, mock_path_to_builder_by_params):
        mock_path_to_builder_by_params.return_value = 'test-url'
        stub_request = StubRequest(args={'fmod_branch': ['master'], 'doc_branch': 'release_v2.3.15'})
        expected_url = 'test-url/builds/16?fmod_branch=master&doc_branch=release_v2.3.15'

        url = path_to_build_by_params(stub_request, 'test-builder', 16, 'test-project')

        self.assertEqual(url, expected_url)