Пример #1
0
def test_gather_plugin_files_from_release():
    repository = dummy_repository_plugin()
    repository.data.file_name = "test.js"
    repository.data.releases = True
    release = AIOGitHubAPIRepositoryRelease(
        {"tag_name": "3", "assets": [{"name": "test.js"}]}
    )
    repository.releases.objects = [release]
    files = [x.name for x in gather_files_to_download(repository)]
    assert "test.js" in files
Пример #2
0
def test_find_file_release():
    repository = dummy_repository_plugin()
    repository.releases.objects = [
        AIOGitHubAPIRepositoryRelease({
            "tag_name": "3",
            "assets": [{
                "name": "test.js"
            }]
        })
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == "release"
Пример #3
0
def test_find_file_release_no_asset():
    repository = dummy_repository_plugin()
    repository.releases.objects = [
        AIOGitHubAPIRepositoryRelease({
            "tag_name": "3",
            "assets": []
        })
    ]
    repository.tree = [
        AIOGitHubAPIRepositoryTreeContent({
            "path": "test.js",
            "type": "blob"
        }, "test/test", "master")
    ]
    find_file_name(repository)
    assert repository.data.file_name == "test.js"
    assert repository.content.path.remote == ""
Пример #4
0
    async def get_releases(
            self,
            prerelease: bool = False,
            returnlimit: int = 5) -> ["AIOGitHubAPIRepositoryRelease"] or list:
        """Retrun a list of repository release objects."""
        _endpoint = f"/repos/{self.full_name}/releases"

        response = await self.client.get(endpoint=_endpoint)
        contents = []

        for content in response or []:
            if len(contents) == returnlimit:
                break
            if not prerelease:
                if content.get("prerelease", False):
                    continue
            contents.append(AIOGitHubAPIRepositoryRelease(content))

        return contents