예제 #1
0
    def test_get_metrics_completed(self, sample_build):
        sample_build["status"] = "success"
        mock_api = MagicMock()
        build = Build(sample_build, mock_api)

        metrics = build.get_metrics()
        assert isinstance(metrics, BuildMetrics)
예제 #2
0
    def build_by_id(self, build_id):
        """
        Get a build by id.

        :param build_id: build id to query.
        :return: Build queried for.
        """
        url = self._create_url('/builds/{build_id}'.format(build_id=build_id))
        return Build(self._paginate(url), self)
예제 #3
0
    def build_by_id(self, build_id: str) -> Build:
        """
        Get a build by id.

        :param build_id: build id to query.
        :return: Build queried for.
        """
        url = self._create_url("/builds/{build_id}".format(build_id=build_id))
        return Build(self._paginate(url), self)  # type: ignore[arg-type]
예제 #4
0
 def test_status_counts(self, sample_build):
     build = Build(sample_build, None)
     assert sample_build["status_counts"][
         "succeeded"] == build.status_counts.succeeded
     assert sample_build["status_counts"][
         "failed"] == build.status_counts.failed
     assert sample_build["status_counts"][
         "started"] == build.status_counts.started
     assert sample_build["status_counts"][
         "timed_out"] == build.status_counts.timed_out
예제 #5
0
 def test_status_counts(self, sample_build):
     build = Build(sample_build, None)
     assert sample_build['status_counts'][
         'succeeded'] == build.status_counts.succeeded
     assert sample_build['status_counts'][
         'failed'] == build.status_counts.failed
     assert sample_build['status_counts'][
         'started'] == build.status_counts.started
     assert sample_build['status_counts'][
         'timed_out'] == build.status_counts.timed_out
예제 #6
0
    def builds_by_version(self, version_id: str, params: Optional[Dict] = None) -> List[Build]:
        """
        Get all builds for a given Evergreen version_id.

        :param version_id: Version Id to query for.
        :param params: Dictionary of parameters to pass to query.
        :return: List of builds for the specified version.
        """
        url = self._create_url("/versions/{version_id}/builds".format(version_id=version_id))
        build_list = self._paginate(url, params)
        return [Build(build, self) for build in build_list]  # type: ignore[arg-type]
예제 #7
0
    def builds_by_version(self, version_id, params=None):
        """
        Get all builds for a given Evergreen version_id.

        :param version_id: Version Id to query for.
        :param params: Dictionary of parameters to pass to query.
        :return: List of builds for the specified version.
        """
        url = self._create_url(
            '/versions/{version_id}/builds'.format(version_id=version_id))
        build_list = self._paginate(url, params)
        return [Build(build, self) for build in build_list]
예제 #8
0
def _flips_for_build(build: Build, next_version: Version,
                     prev_version: Version) -> List[str]:
    """
    Build a list of tasks that flipped in this build.

    :param build: Build to check.
    :param next_version: Next version to check against.
    :param prev_version: Previous version to check against.
    :return: List of tasks that flipped in given build.
    """
    next_build = next_version.build_by_variant(build.build_variant)
    prev_build = prev_version.build_by_variant(build.build_variant)

    tasks = build.get_tasks()
    next_tasks = _create_task_map(next_build.get_tasks())
    prev_tasks = _create_task_map(prev_build.get_tasks())

    return [
        task.display_name for task in tasks
        if _is_task_a_flip(task, next_tasks, prev_tasks)
    ]
예제 #9
0
 def test_get_version(self, sample_build):
     mock_api = MagicMock()
     build = Build(sample_build, mock_api)
     assert mock_api.version_by_id.return_value == build.get_version()
예제 #10
0
    def test_get_metrics_not_completed(self, sample_build):
        sample_build["status"] = "created"
        build = Build(sample_build, None)

        assert not build.get_metrics()
예제 #11
0
 def test_get_tasks(self, sample_build):
     mock_api = MagicMock()
     build = Build(sample_build, mock_api)
     assert mock_api.tasks_by_build.return_value == build.get_tasks()
예제 #12
0
 def test_basic_data(self, sample_build):
     build = Build(sample_build, None)
     assert sample_build["project_id"] == build.project_id
예제 #13
0
 def builds(self) -> Dict[str, Build]:
     """Get a map of build IDs to build objects."""
     return {k: Build(v, self._api) for k, v in self.json["builds"].items()}
예제 #14
0
 def test_get_project_identifier(self, sample_build):
     mock_api = MagicMock()
     build = Build(sample_build, mock_api)
     identifier = build.get_project_identifier()
     assert identifier == mock_api.project_by_id(build.project_id).identifier
예제 #15
0
    def test_get_metrics_not_completed(self, sample_build):
        sample_build['status'] = 'created'
        build = Build(sample_build, None)

        assert not build.get_metrics()