Skip to content

Commit

Permalink
Sync DeploymentStatus class with API spec (#3122)
Browse files Browse the repository at this point in the history
Adds the following attributes:
- log_url
- performed_via_github_app
  • Loading branch information
EnricoMi authored Jan 8, 2025
1 parent c2d3b5e commit b3a06f0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
29 changes: 26 additions & 3 deletions github/DeploymentStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
from __future__ import annotations

from datetime import datetime
from typing import Any
from typing import TYPE_CHECKING, Any

import github.GithubApp
import github.NamedUser
from github.GithubObject import Attribute, CompletableGithubObject, NotSet

if TYPE_CHECKING:
from github.GithubApp import GithubApp
from github.NamedUser import NamedUser


class DeploymentStatus(CompletableGithubObject):
"""
Expand All @@ -64,13 +69,15 @@ class DeploymentStatus(CompletableGithubObject):

def _initAttributes(self) -> None:
self._created_at: Attribute[datetime] = NotSet
self._creator: Attribute[github.NamedUser.NamedUser] = NotSet
self._creator: Attribute[NamedUser] = NotSet
self._deployment_url: Attribute[str] = NotSet
self._description: Attribute[str] = NotSet
self._environment: Attribute[str] = NotSet
self._environment_url: Attribute[str] = NotSet
self._id: Attribute[int] = NotSet
self._log_url: Attribute[str] = NotSet
self._node_id: Attribute[str] = NotSet
self._performed_via_github_app: Attribute[GithubApp] = NotSet
self._repository_url: Attribute[str] = NotSet
self._state: Attribute[str] = NotSet
self._target_url: Attribute[str] = NotSet
Expand All @@ -86,7 +93,7 @@ def created_at(self) -> datetime:
return self._created_at.value

@property
def creator(self) -> github.NamedUser.NamedUser:
def creator(self) -> NamedUser:
self._completeIfNotSet(self._creator)
return self._creator.value

Expand Down Expand Up @@ -115,11 +122,21 @@ def id(self) -> int:
self._completeIfNotSet(self._id)
return self._id.value

@property
def log_url(self) -> str:
self._completeIfNotSet(self._log_url)
return self._log_url.value

@property
def node_id(self) -> str:
self._completeIfNotSet(self._node_id)
return self._node_id.value

@property
def performed_via_github_app(self) -> GithubApp:
self._completeIfNotSet(self._performed_via_github_app)
return self._performed_via_github_app.value

@property
def repository_url(self) -> str:
self._completeIfNotSet(self._repository_url)
Expand Down Expand Up @@ -160,8 +177,14 @@ def _useAttributes(self, attributes: dict[str, Any]) -> None:
self._environment_url = self._makeStringAttribute(attributes["environment_url"])
if "id" in attributes: # pragma no branch
self._id = self._makeIntAttribute(attributes["id"])
if "log_url" in attributes: # pragma no branch
self._log_url = self._makeStringAttribute(attributes["log_url"])
if "node_id" in attributes: # pragma no branch
self._node_id = self._makeStringAttribute(attributes["node_id"])
if "performed_via_github_app" in attributes: # pragma no branch
self._performed_via_github_app = self._makeClassAttribute(
github.GithubApp.GithubApp, attributes["performed_via_github_app"]
)
if "repository_url" in attributes: # pragma no branch
self._repository_url = self._makeStringAttribute(attributes["repository_url"])
if "state" in attributes: # pragma no branch
Expand Down
13 changes: 13 additions & 0 deletions tests/DeploymentStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
# #
################################################################################

from __future__ import annotations

from datetime import datetime, timezone

from . import Framework
Expand All @@ -46,6 +48,14 @@ def setUp(self):
self.status = self.deployment.get_status(388454671)

def testAttributes(self):
self.assertEqual(self.status.created_at, datetime(2020, 8, 26, 14, 32, 51, tzinfo=timezone.utc))
self.assertEqual(self.status.creator.login, "jacquev6")
self.assertEqual(
self.status.deployment_url, "https://api.github.com/repos/jacquev6/PyGithub/deployments/263877258"
)
self.assertEqual(self.status.description, "Deployment queued")
self.assertEqual(self.status.environment, "test")
self.assertEqual(self.status.environment_url, "https://example.com/environment")
self.assertEqual(self.status.id, 388454671)
created_at = datetime(2020, 8, 26, 14, 32, 51, tzinfo=timezone.utc)
self.assertEqual(self.status.created_at, created_at)
Expand All @@ -57,6 +67,9 @@ def testAttributes(self):
self.assertEqual(self.status.description, "Deployment queued")
self.assertEqual(self.status.environment, "test")
self.assertEqual(self.status.environment_url, "https://example.com/environment")
self.assertEqual(self.status.log_url, "https://example.com/deployment.log")
self.assertEqual(self.status.node_id, "MDE2OkRlcGxveW1lbnRTdGF0dXMzODg0NTQ2NzE=")
self.assertIsNone(self.status.performed_via_github_app)
self.assertEqual(
self.status.repository_url,
"https://api.github.com/repos/jacquev6/PyGithub",
Expand Down

0 comments on commit b3a06f0

Please sign in to comment.