Skip to content

Commit

Permalink
Merge branch 'master' into fix-urls-in-authenticated-user
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscaw committed Feb 1, 2023
2 parents 4171693 + 7cf3dfc commit 96de0d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions github/GitRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def zipball_url(self):
self._completeIfNotSet(self._zipball_url)
return self._zipball_url.value

@property
def assets(self):
"""
:type: list of :class:`github.GitReleaseAsset.GitReleaseAsset`
"""
self._completeIfNotSet(self._assets)
return self._assets.value

def delete_release(self):
"""
:calls: `DELETE /repos/{owner}/{repo}/releases/{release_id} <https://docs.github.com/en/rest/reference/repos#delete-a-release>`_
Expand Down Expand Up @@ -333,6 +341,7 @@ def _initAttributes(self):
self._published_at = github.GithubObject.NotSet
self._tarball_url = github.GithubObject.NotSet
self._zipball_url = github.GithubObject.NotSet
self._assets = github.GithubObject.NotSet

def _useAttributes(self, attributes):
if "id" in attributes:
Expand Down Expand Up @@ -369,3 +378,7 @@ def _useAttributes(self, attributes):
self._tarball_url = self._makeStringAttribute(attributes["tarball_url"])
if "zipball_url" in attributes:
self._zipball_url = self._makeStringAttribute(attributes["zipball_url"])
if "assets" in attributes:
self._assets = self._makeListOfClassesAttribute(
github.GitReleaseAsset.GitReleaseAsset, attributes["assets"]
)
2 changes: 2 additions & 0 deletions github/GitRelease.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class GitRelease(CompletableGithubObject):
def _initAttributes(self) -> None: ...
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
@property
def assets(self) -> list[GitReleaseAsset]: ...
@property
def author(self) -> NamedUser: ...
@property
def body(self) -> str: ...
Expand Down
6 changes: 6 additions & 0 deletions tests/GitRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ def testAttributes(self):
),
)
self.assertEqual(repr(release), 'GitRelease(title="Test")')
self.assertEqual(len(release.assets), 1)
self.assertEqual(
repr(release.assets[0]),
'GitReleaseAsset(url="https://api.github.com/repos/'
f'{user}/{repo_name}/releases/assets/{release.raw_data["assets"][0]["id"]}")',
)

def testGetRelease(self):
release_by_id = self.release
Expand Down

0 comments on commit 96de0d1

Please sign in to comment.