示例#1
0
    def test_get_metrics_completed(self, sample_version):
        sample_version['status'] = 'failed'
        mock_api = MagicMock()
        version = Version(sample_version, mock_api)

        metrics = version.get_metrics()
        assert isinstance(metrics, VersionMetrics)
示例#2
0
    def test_get_modules(self, sample_version, sample_manifest):
        mock_api = MagicMock()
        mock_api.manifest.return_value = Manifest(sample_manifest, None)
        version = Version(sample_version, mock_api)
        modules = version.get_modules()

        assert len(modules) == len(sample_manifest["modules"])
示例#3
0
    def test_get_manifest(self, sample_version, sample_manifest):
        mock_api = MagicMock()
        mock_api.manifest.return_value = Manifest(sample_manifest, None)
        version = Version(sample_version, mock_api)
        manifest = version.get_manifest()

        mock_api.manifest.assert_called_with(sample_version['project'], sample_version['revision'])
        assert len(manifest.modules) == len(sample_manifest['modules'])
示例#4
0
    def test_build_by_variant(self, sample_version):
        mock_api = MagicMock()
        version = Version(sample_version, mock_api)
        build_variant = sample_version['build_variants_status'][0]

        build = version.build_by_variant(build_variant['build_variant'])
        assert build == mock_api.build_by_id.return_value
        mock_api.build_by_id.assert_called_once_with(build_variant['build_id'])
示例#5
0
    def test_missing_build_variant_status(self, sample_version):
        del sample_version['build_variants_status']
        version = Version(sample_version, None)

        assert not version.build_variants_status

        sample_version['build_variants_status'] = None
        version = Version(sample_version, None)

        assert not version.build_variants_status
示例#6
0
    def versions_by_project(
        self,
        project_id: str,
        requester: Requester = Requester.GITTER_REQUEST,
        start: Optional[int] = None,
        limit: Optional[int] = None,
    ) -> Iterator[Version]:
        """
        Get the versions created in the specified project.

        :param project_id: Id of project to query.
        :param requester: Type of versions to query.
        :param start: Optional. The revision order number to start after, for pagination.
        :param limit: Optional. The number of versions to be returned per page of pagination.
        :return: Generator of versions.
        """
        url = self._create_url(f"/projects/{project_id}/versions")
        params: Dict[str, Any] = {"requester": requester}
        if start:
            params["start"] = start
        if limit:
            params["limit"] = limit
        version_list = self._lazy_paginate(url, params)
        return (Version(version, self)
                for version in version_list)  # type: ignore[arg-type]
示例#7
0
    def version_by_id(self, version_id: str) -> Version:
        """
        Get version by version id.

        :param version_id: Id of version to query.
        :return: Version queried for.
        """
        url = self._create_url(f"/versions/{version_id}")
        return Version(self._paginate(url), self)  # type: ignore[arg-type]
示例#8
0
    def version_by_id(self, version_id):
        """
        Get version by version id.

        :param version_id: Id of version to query.
        :return: Version queried for.
        """
        url = self._create_url(
            '/versions/{version_id}'.format(version_id=version_id))
        return Version(self._paginate(url), self)
示例#9
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)
    ]
示例#10
0
    def recent_version_by_project(self, project_id, params=None):
        """
        Get recent versions created in specified project.

        :param project_id: Id of project to query.
        :param params: parameters to pass to endpoint.
        :return: List of recent versions.
        """
        url = self._create_url('/projects/{project_id}/recent_versions'.format(
            project_id=project_id))
        version_list = self._paginate(url, params)
        return [Version(version, self) for version in version_list]
示例#11
0
    def test_is_patch(self, sample_version):
        version = Version(sample_version, None)
        assert not version.is_patch()

        sample_version['version_id'] = SAMPLE_VERSION_ID_FOR_PATCH
        version = Version(sample_version, None)
        assert version.is_patch()
示例#12
0
    def test_is_patch(self, sample_version):
        sample_version["requester"] = Requester.GITTER_REQUEST.evg_value()
        version = Version(sample_version, None)
        assert not version.is_patch()

        sample_version["requester"] = Requester.PATCH_REQUEST.evg_value()
        version = Version(sample_version, None)
        assert version.is_patch()
示例#13
0
    def test_is_patch_with_requester(self, sample_version):
        del sample_version["requester"]
        version = Version(sample_version, None)
        assert not version.is_patch()

        sample_version["version_id"] = SAMPLE_VERSION_ID_FOR_PATCH
        version = Version(sample_version, None)
        assert version.is_patch()
示例#14
0
    def versions_by_project(
        self, project_id: str, requester: Requester = Requester.GITTER_REQUEST
    ) -> Iterator[Version]:
        """
        Get the versions created in the specified project.

        :param project_id: Id of project to query.
        :param requester: Type of versions to query.
        :return: Generator of versions.
        """
        url = self._create_url("/projects/{project_id}/versions".format(project_id=project_id))
        params = {"requester": requester.name.lower()}
        version_list = self._lazy_paginate(url, params)
        return (Version(version, self) for version in version_list)  # type: ignore[arg-type]
示例#15
0
文件: api.py 项目: zamj/evergreen.py
    def versions_by_project(self,
                            project_id,
                            requester=Requester.GITTER_REQUEST):
        """
        Get the versions created in the specified project.

        :param project_id: Id of project to query.
        :param requester: Type of versions to query.
        :return: Generator of versions.
        """
        url = self._create_url(
            '/projects/{project_id}/versions'.format(project_id=project_id))
        params = {'requester': requester.name.lower()}
        version_list = self._lazy_paginate(url, params)
        return (Version(version, self) for version in version_list)
示例#16
0
    def recent_version_by_project(
            self,
            project_id: str,
            params: Optional[Dict] = None) -> List[Version]:
        """
        Get recent versions created in specified project.

        :param project_id: Id of project to query.
        :param params: parameters to pass to endpoint.
        :return: List of recent versions.
        """
        url = self._create_url("/projects/{project_id}/recent_versions".format(
            project_id=project_id))
        version_list = self._paginate(url, params)
        return [Version(version, self)
                for version in version_list]  # type: ignore[arg-type]
示例#17
0
    def test_get_metrics_uncompleted(self, sample_version):
        sample_version['status'] = 'created'
        version = Version(sample_version, None)

        assert not version.get_metrics()
示例#18
0
    def test_failed_version_is_completed(self, sample_version):
        sample_version['status'] = 'failed'
        version = Version(sample_version, None)

        assert version.is_completed()
示例#19
0
    def test_started_version_is_not_completed(self, sample_version):
        sample_version['status'] = 'started'
        version = Version(sample_version, None)

        assert not version.is_completed()
示例#20
0
    def test_get_patch_for_patch(self, sample_version):
        sample_version['version_id'] = SAMPLE_VERSION_ID_FOR_PATCH
        mock_api = MagicMock()
        version = Version(sample_version, mock_api)

        assert version.get_patch() == mock_api.patch_by_id.return_value
示例#21
0
    def test_get_patch_for_non_patch(self, sample_version):
        mock_api = MagicMock()
        version = Version(sample_version, mock_api)

        assert not version.get_patch()
示例#22
0
    def test_get_patch_for_non_patch(self, sample_version):
        sample_version["requester"] = Requester.GITTER_REQUEST.evg_value()
        mock_api = MagicMock()
        version = Version(sample_version, mock_api)

        assert not version.get_patch()
示例#23
0
 def test_get_builds(self, sample_version):
     mock_api = MagicMock()
     version = Version(sample_version, mock_api)
     assert version.get_builds() == mock_api.builds_by_version.return_value
示例#24
0
    def test_started_version_is_not_completed(self, sample_version):
        sample_version["status"] = "started"
        version = Version(sample_version, None)

        assert not version.is_completed()
示例#25
0
    def test_failed_version_is_completed(self, sample_version):
        sample_version["status"] = "failed"
        version = Version(sample_version, None)

        assert version.is_completed()
示例#26
0
    def test_get_metrics_uncompleted(self, sample_version):
        sample_version["status"] = "created"
        version = Version(sample_version, None)

        assert not version.get_metrics()
示例#27
0
 def test_build_variant_status(self, sample_version):
     version = Version(sample_version, None)
     assert len(sample_version['build_variants_status']) == len(version.build_variants_status)
示例#28
0
 def test_dates_are_correct(self, sample_version):
     version = Version(sample_version, None)
     assert isinstance(version.create_time, datetime)
示例#29
0
 def test_get_attributes(self, sample_version):
     version = Version(sample_version, None)
     assert version.version_id == sample_version['version_id']
示例#30
0
 def test_requester(self, requester_value, sample_version):
     sample_version["requester"] = requester_value.evg_value()
     version = Version(sample_version, None)
     assert version.requester == requester_value